From d2581332dba8ee9af2521dbe192ab0650f37d983 Mon Sep 17 00:00:00 2001 From: John Johansen Date: Tue, 9 Nov 2010 11:34:59 -0800 Subject: [PATCH] This is part of a serious of patches to cleanup expr nodes, by separating out functionality and reducing the number of dynamic casts. --- parser/libapparmor_re/regexp.y | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/parser/libapparmor_re/regexp.y b/parser/libapparmor_re/regexp.y index b2d7c517b..899a6f417 100644 --- a/parser/libapparmor_re/regexp.y +++ b/parser/libapparmor_re/regexp.y @@ -114,6 +114,13 @@ } }; + class InnerNode : public Node { + public: + InnerNode() : Node() { }; + InnerNode(Node *left) : Node(left) {}; + InnerNode(Node *left, Node *right) : Node(left, right) { }; + }; + /* Match nothing (//). */ class EpsNode : public Node { public: @@ -331,10 +338,10 @@ }; /* Match a pair of consecutive nodes. */ - class CatNode : public Node { + class CatNode : public InnerNode { public: CatNode(Node *left, Node *right) : - Node(left, right) { } + InnerNode(left, right) { } void compute_nullable() { nullable = child[0]->nullable && child[1]->nullable; @@ -378,10 +385,10 @@ }; /* Match a node zero or more times. (This is a unary operator.) */ - class StarNode : public Node { + class StarNode : public InnerNode { public: StarNode(Node *left) : - Node(left) + InnerNode(left) { nullable = true; } @@ -414,10 +421,10 @@ }; /* Match a node one or more times. (This is a unary operator.) */ - class PlusNode : public Node { + class PlusNode : public InnerNode { public: PlusNode(Node *left) : - Node(left) { } + InnerNode(left) { } void compute_nullable() { nullable = child[0]->nullable; @@ -451,10 +458,10 @@ }; /* Match one of two alternative nodes. */ - class AltNode : public Node { + class AltNode : public InnerNode { public: AltNode(Node *left, Node *right) : - Node(left, right) { } + InnerNode(left, right) { } void compute_nullable() { nullable = child[0]->nullable || child[1]->nullable;