Vcsn
2.3
Be Rational
|
State and public interface for rational expression parsing. More...
#include <driver.hh>
Public Member Functions | |
driver (const dyn::context &ctx, rat::identities ids) | |
~driver () | |
void | context (const dyn::context &ctx) |
Set the expressionset to use from this context. More... | |
void | context (const std::string &ctx) |
Set the expressionset to use from its context name. More... | |
dyn::context | context () const |
Get the current context. More... | |
rat::identities | identities () const |
Get the identities. More... | |
void | tape_push () |
Push a new tape number on the stack. More... | |
void | tape_pop () |
Pop the tape stack. More... | |
void | tape_inc (const location &l) |
Increment the top most tape. More... | |
dyn::expression | parse (std::istream &is, const location &l=location{}) |
Parse this stream. More... | |
void | error (const location &l, const std::string &m) |
Report an error m at l. More... | |
void | invalid (const location &l, const std::string &s) |
The string s is invalid at l. More... | |
dyn::label | make_label (const location &loc, const std::string &s, const dyn::context &ctx) |
From a string, generate a label. More... | |
dyn::expression | make_atom (const location &loc, const std::string &s) |
From a string, generate an expression. More... | |
dyn::expression | make_expression (const location &loc, const class_t &c, bool accept) |
From a label class, generate an expression. More... | |
dyn::weight | make_weight (const location &loc, const std::string &s) |
From a string, generate a weight. More... | |
Public Attributes | |
std::string | errors |
The error messages. More... | |
std::unique_ptr< yyFlexLexer > | scanner_ |
The scanner. More... | |
Private Attributes | |
location | location_ |
The inital location. More... | |
dyn::context | ctx_ |
The context used to read the expression. More... | |
rat::identities | ids_ |
The identities to apply. More... | |
dyn::expression | result_ |
The parsed expression. More... | |
std::vector< unsigned > | tapes_ = {0} |
The stack of tape numbers. More... | |
std::vector< dyn::context > | tape_ctx_ = {} |
The context for each tape. If single-tape, [0] is ctx_. More... | |
Friends | |
class | parser |
State and public interface for rational expression parsing.
vcsn::rat::driver::driver | ( | const dyn::context & | ctx, |
rat::identities | ids | ||
) |
void vcsn::rat::driver::context | ( | const dyn::context & | ctx | ) |
Set the expressionset to use from this context.
Definition at line 32 of file driver.cc.
References vcsn::rat::ctx(), ctx_, vcsn::dyn::num_tapes(), vcsn::dyn::project(), and tape_ctx_.
Referenced by vcsn::rat::ctx().
void vcsn::rat::driver::context | ( | const std::string & | ctx | ) |
Set the expressionset to use from its context name.
Definition at line 44 of file driver.cc.
References context(), and vcsn::dyn::make_context().
dyn::context vcsn::rat::driver::context | ( | ) | const |
Get the current context.
Depends on the current tape.
Definition at line 27 of file driver.cc.
References tape_ctx_, and tapes_.
Referenced by context(), driver(), make_atom(), and make_expression().
void vcsn::rat::driver::error | ( | const location & | l, |
const std::string & | m | ||
) |
rat::identities vcsn::rat::driver::identities | ( | ) | const |
Get the identities.
Definition at line 49 of file driver.cc.
References ids_.
Referenced by vcsn::rat::ids().
void vcsn::rat::driver::invalid | ( | const location & | l, |
const std::string & | s | ||
) |
dyn::expression vcsn::rat::driver::make_atom | ( | const location & | loc, |
const std::string & | s | ||
) |
From a string, generate an expression.
Definition at line 143 of file driver.cc.
References context(), ctx_, ids_, make_label(), and vcsn::dyn::to_expression().
Referenced by vcsn::rat::parser::parse().
dyn::expression vcsn::rat::driver::make_expression | ( | const location & | loc, |
const class_t & | c, | ||
bool | accept = true |
||
) |
From a label class, generate an expression.
Definition at line 160 of file driver.cc.
References context(), ctx_, vcsn::detail::front(), ids_, and vcsn::dyn::to_expression().
Referenced by vcsn::rat::parser::parse().
dyn::label vcsn::rat::driver::make_label | ( | const location & | loc, |
const std::string & | s, | ||
const dyn::context & | ctx | ||
) |
From a string, generate a label.
Definition at line 125 of file driver.cc.
References vcsn::dyn::read_label(), vcsn::require(), and vcsn::res.
Referenced by make_atom().
dyn::weight vcsn::rat::driver::make_weight | ( | const location & | loc, |
const std::string & | s | ||
) |
From a string, generate a weight.
Definition at line 182 of file driver.cc.
References ctx_, vcsn::dyn::read_weight(), vcsn::require(), and vcsn::res.
Referenced by vcsn::rat::parser::parse().
Parse this stream.
Definition at line 102 of file driver.cc.
References vcsn::detail::debug_level(), vcsn::rat::debug_level_(), vcsn::rat::parser::parse(), and vcsn::rat::parser::set_debug_level().
void vcsn::rat::driver::tape_inc | ( | const location & | l | ) |
Increment the top most tape.
Definition at line 64 of file driver.cc.
References tape_ctx_, and tapes_.
Referenced by vcsn::rat::parser::parse().
void vcsn::rat::driver::tape_pop | ( | ) |
Pop the tape stack.
Definition at line 59 of file driver.cc.
References tapes_.
Referenced by vcsn::rat::parser::parse().
void vcsn::rat::driver::tape_push | ( | ) |
Push a new tape number on the stack.
Definition at line 54 of file driver.cc.
References tapes_.
Referenced by vcsn::rat::parser::parse().
|
private |
The context used to read the expression.
Definition at line 79 of file driver.hh.
Referenced by context(), make_atom(), make_expression(), make_weight(), and vcsn::rat::parser::parse().
std::string vcsn::rat::driver::errors |
|
private |
The identities to apply.
Definition at line 81 of file driver.hh.
Referenced by identities(), make_atom(), and make_expression().
|
private |
The inital location.
Definition at line 77 of file driver.hh.
Referenced by vcsn::rat::parser::parse().
|
private |
The parsed expression.
Definition at line 83 of file driver.hh.
Referenced by vcsn::rat::parser::parse().
std::unique_ptr<yyFlexLexer> vcsn::rat::driver::scanner_ |
The scanner.
Definition at line 57 of file driver.hh.
Referenced by vcsn::rat::parser::parse(), and vcsn::rat::yylex().
|
private |
The context for each tape. If single-tape, [0] is ctx_.
Definition at line 92 of file driver.hh.
Referenced by context(), vcsn::rat::parser::parse(), and tape_inc().
|
private |
The stack of tape numbers.
The concept of tape number does not suffice. For instance, it cannot deal with (a|b)|(x|y)
which is a lat<lat<lan, lan>, lat<lan, lan>>
. Not that it really matters as of today...
Definition at line 90 of file driver.hh.
Referenced by context(), tape_inc(), tape_pop(), and tape_push().