Vcsn  2.5.dev
Be Rational
driver.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <lib/vcsn/rat/fwd.hh>
4 #include <lib/vcsn/rat/parse.hh>
5 #include <vcsn/core/rat/fwd.hh>
7 #include <vcsn/dyn/context.hh>
8 #include <vcsn/dyn/value.hh>
9 #include <vcsn/misc/export.hh>
10 #include <vcsn/misc/location.hh>
11 
12 namespace vcsn
13 {
14  namespace rat
15  {
18  {
19  public:
21  ~driver();
22 
24  void context(const dyn::context& ctx);
25 
27  void context(const std::string& ctx);
28 
31  dyn::context context() const;
32 
35 
37  void tape_push();
38 
40  void tape_pop();
41 
43  void tape_inc(const location& l);
44 
46  dyn::expression parse(std::istream& is, const location& l = location{});
47 
49  void error(const location& l, const std::string& m);
51  ATTRIBUTE_NORETURN
52  void invalid(const location& l, const std::string& s);
53 
55  std::string errors;
57  std::unique_ptr<yyFlexLexer> scanner_;
58 
60  dyn::label make_label(const location& loc, const std::string& s,
61  const dyn::context& ctx);
62 
64  dyn::expression make_atom(const location& loc, const std::string& s);
65 
68  const class_t& c, bool accept);
69 
71  dyn::weight make_weight(const location& loc, const std::string& s);
72 
73  private:
74  friend class parser;
75 
90  std::vector<unsigned> tapes_ = {0};
92  std::vector<dyn::context> tape_ctx_ = {};
93  };
94  }
95 }
Abstract a location.
Definition: location.hh:47
rat::identities ids_
The identities to apply.
Definition: driver.hh:81
A dyn Value/ValueSet.
Definition: fwd.hh:29
value_impl< detail::expression_tag > expression
Definition: fwd.hh:31
std::unique_ptr< yyFlexLexer > scanner_
The scanner.
Definition: driver.hh:57
dyn::context ctx_
The context used to read the expression.
Definition: driver.hh:79
Define the vcsn::rat::parser class.
label make_label(const context &ctx, const std::string &s, const std::string &format="default")
Build a label from a string.
Definition: algos.hxx:90
expression make_expression(const context &ctx, const std::string &s, identities ids={}, const std::string &format="default")
Read an expression from a stream.
Definition: algos.hxx:71
weight make_weight(const context &ctx, const std::string &s)
Build a weight from a string.
Definition: algos.hxx:125
A Bison parser.
Definition: parse.hh:299
std::set< std::pair< std::string, std::string > > class_t
A set of label ranges.
Definition: fwd.hh:12
Template-less root for contexts.
Definition: context.hh:16
std::string errors
The error messages.
Definition: driver.hh:55
#define LIBVCSN_API
Definition: export.hh:8
location location_
The inital location.
Definition: driver.hh:77
Definition: a-star.hh:8
static identities ids(const driver &d)
Get the identities of the driver.
Definition: parse.cc:89
::vcsn::rat::identities identities
Sets of identities on expressions.
Definition: fwd.hh:17
An expressionset can implement several different sets of identities on expressions.
Definition: identities.hh:20
State and public interface for rational expression parsing.
Definition: driver.hh:17
static dyn::context ctx(const driver &d)
Get the context of the driver.
Definition: parse.cc:82
dyn::expression result_
The parsed expression.
Definition: driver.hh:83