Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Parser Struct Template Reference
[Series]

Parser class used in the parse() function. More...

List of all members.

Public Member Functions

void parse (Element< S, T > &exp)
 Do the parsing.

bool error () const
 Return true when an error occured.

const std::string & error_msg () const
 Return the error message.


Protected Member Functions

void parse_error (const std::string &msg="parse_error.") throw (const std::string&)
 Generate a parse error.

void accept (token_e tok)
 Accept token, or generate an error.

void parse_exp (Element< S, T > &exp)
 exp ::= term ('+' term)*

void parse_term (Element< S, T > &exp)
 term ::= right_weighted ('.'? right_weighted)*

void parse_right_weighted (Element< S, T > &exp)
 right_weighted ::= left_weighted (' ' weight)*

void parse_left_weighted (Element< S, T > &exp)
 left_weighted ::= weight ' ' left_weighted | stared

void parse_stared (Element< S, T > &exp)
 stared ::= factor '*'*

void parse_factor (Element< S, T > &exp)
 factor ::= 1 | 0 | word | '(' exp ')'

void trace (const std::string &msg)
 Trace parsing.

template<class Misc> void trace (const std::string &msg, const Misc &v)
 Trace parsing.


Detailed Description

template<class S, class T>
struct vcsn::algebra::Parser< S, T >

Parser class used in the parse() function.

This class handles rational expression parsing, once a Lexer has been created.

Ideally, we would like to parse:

exp ::= '(' exp ')' | exp '+' exp | exp '.' exp | exp exp | exp '*' | weight ' ' exp | exp ' ' weight | 0 | 1 | word

But this grammar has to be changed to allow a classical LL(2) parsing:

exp ::= term ('+' term)* term ::= right_weighted ('.'? right_weighted)* right_weighted ::= left_weighted (' ' weight)* left_weighted ::= weight ' ' left_weighted | stared stared ::= factor '*'* factor ::= '(' exp ')' | word | 0 | 1


Member Function Documentation

void accept token_e  tok  )  [inline, protected]
 

Accept token, or generate an error.

This function asks the lexer whether the first input token matches the argument or not. When matching is successfull, the first input token is eaten, an error is risen else.

Parameters:
tok The token to match.


Generated on Thu Dec 18 14:14:27 2003 for Vaucanson by doxygen 1.3.4