class Expression

This class is used to parse a string boolean expression into an internal tree represenation and to evaluate or reduce the expression for a given user

Public Methods

Expression ()
Constructor
Expression (const string& expression)
Constructs this Expression given expression
~Expression ()
Destroys this object
bool isNull ()
string toString () const
Returns a string representation of this Expression
string toLogString () const
For logging purpose
bool evaluate (ExpressionEvaluator& evaluator) const
Use this method when it is possible for the evaluator to evaluate all non-boolean expressions
int reduce (ExpressionEvaluator& evaluator, Expression& expr) const
Use this method when it may not be possible for the evaluator to evaluate all non-boolean expressions
void visit (ExpressionVisitor& visitor) const
Use this method to visit all the non-boolean expressions

Documentation

This class is used to parse a string boolean expression into an internal tree represenation and to evaluate or reduce the expression for a given user.
Grammar:

EXPR      ->  AEXPR   { OR AEXPR }
AEXPR     ->  NEXPER  { AND NEXPR }
NEXPER    ->  { NOT NEXPR } | PEXPER
PEXPER    ->  LEXPER AOP REXPER | ( EXPER )
LEXPER    ->  one non-empty string
REXPER    ->  one or more non-empty strings
AOP       ->  = | != | < | <= | > | >=
NOT       ->  ! 
AND       ->  && | & 
OR        ->  || | | 

Precedence:

Following is the list of operators we support. They 
are listed from highest to lowest precedence.

{ =, != , <, <= , >, >= }, !, { &&, &}, { ||, | }.

Parenthesis are of course optional. And as usual they can be used
for groupings.

Blank spaces have no meaning unless they are used to delimit the 
right hand side of an equality/or inequality operator. This is really
where we differ from the C expression parser.

The following two partial expressions have the same meaning:
 CN   =     Denis   The    Menace     
CN=Denis The Menace
Expression()
Constructor

Expression(const string& expression)
Constructs this Expression given expression.
Throws:
ParserException if the expression does not conform to the grammar.
Parameters:
expression - string that holds the boolean expression

~Expression()
Destroys this object

bool isNull()

string toString() const
Returns a string representation of this Expression

string toLogString() const
For logging purpose

bool evaluate(ExpressionEvaluator& evaluator) const
Use this method when it is possible for the evaluator to evaluate all non-boolean expressions

int reduce(ExpressionEvaluator& evaluator, Expression& expr) const
Use this method when it may not be possible for the evaluator to evaluate all non-boolean expressions. The resulting expression is placed in the out parameter expr
Returns:
1 or 0 if it was possible to evaluate the whole tree. -1 otherwise and the resulting expression is placed in expr.

void visit(ExpressionVisitor& visitor) const
Use this method to visit all the non-boolean expressions


This class has no child classes.
Author:
Srilekha Mudumbai Abdelilah Essiari
Version:
1.1 00/05/01

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de