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

[more] Expression ()
Constructor
[more] Expression (const string& expression)
Constructs this Expression given expression.
[more] ~Expression ()
Destroys this object
[more]bool isNull ()
[more]string toString () const
Returns a string representation of this Expression.
[more]string toLogString () const
For logging purpose
[more]bool evaluate (ExpressionEvaluator& evaluator) const
Use this method when it is possible for the evaluator to evaluate all non-boolean expressions.
[more]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.
[more]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
  * 

o Expression()
Constructor

o 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

o ~Expression()
Destroys this object

obool isNull()

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

ostring toLogString() const
For logging purpose

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

oint 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.

ovoid 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 HTML hierarchy of classes or Java



This page was generated with the help of DOC++.