#include <expression.h>
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 } |
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