Series
[Algebra]

Collaboration diagram for Series:


Files

file  krat_exp_parser.hh
 This file declares the parse() function.

Namespaces

namespace  vcsn::algebra::krat_exp_lexing
 Misc. declarations used for rational expression lexing.

Classes

struct  SeriesBase
 Structural element of series K<A*> from a free monoid A* to a semiring K. More...
struct  series_traits
 Meta information about series. More...
struct  mute_series_impl
struct  mute_series_traits
struct  dynamic_traits< algebra::SeriesBase< Self > >
struct  virtual_types< algebra::SeriesBase< S > >
class  MetaElement< algebra::SeriesBase< Self >, T >
 Services of every series. More...
class  KRatExpToken
 Schrödinger's token for rational expression lexing. More...
struct  Lexer
 Lexer class for the rational expression parser. More...
struct  Parser
 Parser class used in the parse() function. More...

Functions

template<typename S, typename T>
Element< S, T > vcsn::transpose (const algebra::SeriesBase< S > &s, const T &t)
 returns a fresh series that is the transposed of the argument.
template<typename S, typename T>
bool vcsn::is_letter_support (const Element< S, T > &s)
 Returns true if the support of the series is only composed of letters.
template<typename S1, typename S2, typename T1, typename T2>
void vcsn::extract_support (Element< S1, T1 > &, Element< S2, T2 > &)
 Make the first series be the support of the second.
template<class S, class T>
Element< S, T > vcsn::hadamard (const Element< S, T > &lhs, const Element< S, T > &rhs)
 Return the hadamard product of lhs and rhs.
template<class S, class T>
std::pair< bool, std::string > vcsn::algebra::parse (const std::string &from, Element< S, T > &exp, bool lex_trace=false, bool parse_trace=false)
 Parse a rational expression.

Function Documentation

std::pair< bool, std::string > parse const std::string &  from,
Element< S, T > &  exp,
bool  lex_trace = false,
bool  parse_trace = false
 

Parse a rational expression.

This functions parses any numerical rational expression. The grammar is:

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

Priority for operators is, from the most important to the least important:

  • * (star), to star a series.
  • ' ' (space), to weight a series either on the right or on the left.
  • . (dot), to concatenate two series.
  • + (plus), to do the union of two series.

This function returns a pair which first element is a Boolean indicating whether an error occured or not. The second element is an error message when a parse error have been ecountered.

Note that this function requires exception support from the compiler.

Parameters:
from The rational expression, as a string.
exp The element to store the result in. Be sure its set is correct before calling parse.
lex_trace Enable lexer trace (for debuging purposes).
parse_trace Enable parser trace (for debuging purposes).
Author:
Yann Régis-Gianas <yann@lrde.epita.fr>, Thomas Claveirole <thomas@lrde.epita.fr>

Definition at line 689 of file krat_exp_parser.hxx.

References Parser::error(), Parser::error_msg(), Lexer::lex(), and Parser::parse().

Referenced by vcsn::xml::tools::add_xml_label(), vcsn::xml::tools::get_series(), vcsn::VCSN_CONTEXT_NAMESPACE::make_rat_exp(), usual_converter_exp::operator()(), and usual_converter_poly::operator()().


Generated on Sat Jul 29 17:28:30 2006 for Vaucanson by  doxygen 1.4.6