Vcsn  2.8
Be Rational
vcsn::rat::driver Class Reference

State and public interface for rational expression parsing. More...

#include <driver.hh>

Collaboration diagram for vcsn::rat::driver:

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

Static Public Member Functions

static int debug_level ()
 The nesting limit for parser traces, as specified per $YYDEBUG. More...
 

Public Attributes

std::string errors
 The error messages. More...
 
std::unique_ptr< yyFlexLexerscanner_
 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::contexttape_ctx_ = {}
 The context for each tape. If single-tape, [0] is ctx_. More...
 

Friends

class parser
 

Detailed Description

State and public interface for rational expression parsing.

Definition at line 17 of file driver.hh.

Constructor & Destructor Documentation

◆ driver()

vcsn::rat::driver::driver ( const dyn::context ctx,
rat::identities  ids 
)

Definition at line 18 of file driver.cc.

References context().

Here is the call graph for this function:

◆ ~driver()

vcsn::rat::driver::~driver ( )

Definition at line 25 of file driver.cc.

Member Function Documentation

◆ context() [1/3]

void vcsn::rat::driver::context ( const dyn::context ctx)

Set the expressionset to use from this context.

Definition at line 33 of file driver.cc.

References vcsn::rat::ctx(), ctx_, vcsn::dyn::num_tapes(), vcsn::dyn::project(), and tape_ctx_.

Referenced by vcsn::rat::ctx().

Here is the call graph for this function:

◆ context() [2/3]

void vcsn::rat::driver::context ( const std::string &  ctx)

Set the expressionset to use from its context name.

Definition at line 45 of file driver.cc.

References context(), and vcsn::dyn::make_context().

Here is the call graph for this function:

◆ context() [3/3]

dyn::context vcsn::rat::driver::context ( ) const

Get the current context.

Depends on the current tape.

Definition at line 28 of file driver.cc.

References tape_ctx_, and tapes_.

Referenced by context(), driver(), make_atom(), and make_expression().

◆ debug_level()

int vcsn::rat::driver::debug_level ( )
static

The nesting limit for parser traces, as specified per $YYDEBUG.

Definition at line 89 of file driver.cc.

References vcsn::res.

Referenced by parse(), and vcsn::rat::parser::parse().

◆ error()

void vcsn::rat::driver::error ( const location l,
const std::string &  m 
)

Report an error m at l.

Definition at line 73 of file driver.cc.

References errors, vcsn::detail::print_caret(), and scanner_.

Referenced by vcsn::rat::parser::error().

Here is the call graph for this function:

◆ identities()

rat::identities vcsn::rat::driver::identities ( ) const

Get the identities.

Definition at line 50 of file driver.cc.

References ids_.

Referenced by vcsn::rat::ids().

◆ invalid()

void vcsn::rat::driver::invalid ( const location l,
const std::string &  s 
)

The string s is invalid at l.

Definition at line 83 of file driver.cc.

◆ make_atom()

dyn::expression vcsn::rat::driver::make_atom ( const location loc,
const std::string &  s 
)

From a string, generate an expression.

Definition at line 144 of file driver.cc.

References context(), ctx_, ids_, make_label(), and vcsn::dyn::to_expression().

Referenced by vcsn::rat::parser::parse().

Here is the call graph for this function:

◆ make_expression()

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 161 of file driver.cc.

References context(), ctx_, vcsn::detail::front(), ids_, and vcsn::dyn::to_expression().

Referenced by vcsn::rat::parser::parse().

Here is the call graph for this function:

◆ make_label()

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 126 of file driver.cc.

References vcsn::dyn::read_label(), vcsn::require(), and vcsn::res.

Referenced by make_atom().

Here is the call graph for this function:

◆ make_weight()

dyn::weight vcsn::rat::driver::make_weight ( const location loc,
const std::string &  s 
)

From a string, generate a weight.

Definition at line 183 of file driver.cc.

References ctx_, vcsn::dyn::read_weight(), vcsn::require(), and vcsn::res.

Referenced by vcsn::rat::parser::parse().

Here is the call graph for this function:

◆ parse()

auto vcsn::rat::driver::parse ( std::istream &  is,
const location l = location{} 
)

Parse this stream.

Definition at line 102 of file driver.cc.

References debug_level(), errors, location_, result_, and scanner_.

Here is the call graph for this function:

◆ tape_inc()

void vcsn::rat::driver::tape_inc ( const location l)

Increment the top most tape.

Definition at line 65 of file driver.cc.

References tape_ctx_, and tapes_.

Referenced by vcsn::rat::parser::parse().

◆ tape_pop()

void vcsn::rat::driver::tape_pop ( )

Pop the tape stack.

Definition at line 60 of file driver.cc.

References tapes_.

Referenced by vcsn::rat::parser::parse().

◆ tape_push()

void vcsn::rat::driver::tape_push ( )

Push a new tape number on the stack.

Definition at line 55 of file driver.cc.

References tapes_.

Referenced by vcsn::rat::parser::parse().

Friends And Related Function Documentation

◆ parser

friend class parser
friend

Definition at line 78 of file driver.hh.

Member Data Documentation

◆ ctx_

dyn::context vcsn::rat::driver::ctx_
private

The context used to read the expression.

Definition at line 83 of file driver.hh.

Referenced by context(), make_atom(), make_expression(), make_weight(), and vcsn::rat::parser::parse().

◆ errors

std::string vcsn::rat::driver::errors

The error messages.

Definition at line 55 of file driver.hh.

Referenced by error(), and parse().

◆ ids_

rat::identities vcsn::rat::driver::ids_
private

The identities to apply.

Definition at line 85 of file driver.hh.

Referenced by identities(), make_atom(), make_expression(), and vcsn::rat::parser::parse().

◆ location_

location vcsn::rat::driver::location_
private

The inital location.

Definition at line 81 of file driver.hh.

Referenced by parse(), and vcsn::rat::parser::parse().

◆ result_

dyn::expression vcsn::rat::driver::result_
private

The parsed expression.

Definition at line 87 of file driver.hh.

Referenced by parse(), and vcsn::rat::parser::parse().

◆ scanner_

std::unique_ptr<yyFlexLexer> vcsn::rat::driver::scanner_

The scanner.

Definition at line 57 of file driver.hh.

Referenced by error(), parse(), vcsn::rat::parser::parse(), and vcsn::rat::yylex().

◆ tape_ctx_

std::vector<dyn::context> vcsn::rat::driver::tape_ctx_ = {}
private

The context for each tape. If single-tape, [0] is ctx_.

Definition at line 96 of file driver.hh.

Referenced by context(), vcsn::rat::parser::parse(), and tape_inc().

◆ tapes_

std::vector<unsigned> vcsn::rat::driver::tapes_ = {0}
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 94 of file driver.hh.

Referenced by context(), tape_inc(), tape_pop(), and tape_push().


The documentation for this class was generated from the following files: