Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

expression< Type > Class Template Reference

#include <expression.h>

List of all members.

Public Member Functions

void push_parsers (grammar_to_parser::parsers &l)
Type evaluate ()
Type evaluate (Type left_result)
Type get_left_value ()
int get_priority ()

Protected Attributes

grammar_to_parser::non_terminal<
add > 
m_add
grammar_to_parser::non_terminal<
substract > 
m_substract
grammar_to_parser::non_terminal<
multiply > 
m_multiply
grammar_to_parser::non_terminal<
divide > 
m_divide
grammar_to_parser::choice<
subexpression > 
m_subexpr

Private Types

typedef std::string std_string
enum  priorities { plus_minus = 0, multiply_divide = 1, fnc_value_parenthesis = 2 }


Detailed Description

template<class Type>
class expression< Type >

The class demonstrates how to declare parser class from grammar deinition. For recognizing arithmetic expressions is defined following grammar: E->S+E | S-E | S*E | S/E | S S->(E) | value | functions

Then: E is declared as class expression S as 'subexpression' S+E as 'add' S-E as 'substract', etc. To support non_terminal parser type, the method push_parsers() must be implemented, which defines the order of embedded symbols, i.e. add is used as non_terminal<add> and consists of choice< expression<Type> > and terminal<'+'> and choice< expression<Type> >.

'Type' is used for value parser and is filled using istream::>> operator functionality - in example is used Type=float


The documentation for this class was generated from the following file:
Generated on Sun Jul 2 18:39:44 2006 for grammar2parser.kdevelop by  doxygen 1.4.1