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

vcsn::algebra::Parser Struct Template Reference
[Series]

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

List of all members.

Public Methods

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 Methods

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

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 Wed Jul 2 19:09:13 2003 for Vaucanson by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002