Vcsn  2.2a
Be Rational
context-parser.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <sstream>
4 #include <string>
5 
7 #include <vcsn/dyn/type-ast.hh>
8 #include <vcsn/misc/set.hh>
9 #include <vcsn/misc/stream.hh>
10 
11 namespace vcsn
12 {
13  namespace ast
14  {
16  {
17  public:
18  context_parser(std::istringstream& is)
19  : is_(is)
20  {}
21 
23  std::shared_ptr<ast_node> parse();
24 
26  std::shared_ptr<ast_node> parse_context();
27 
28  private:
30  void skip_space_();
31 
33  int peek_();
34 
36  char eat_(char c);
37 
39  const std::string& eat_(const std::string& s);
40 
43  void check_eof_(std::shared_ptr<ast_node> res);
44 
47  std::string word_();
48 
52  std::string parameters_();
53 
55  std::shared_ptr<ast_node> any_();
56 
60  std::shared_ptr<const genset> genset_();
61 
64  std::shared_ptr<const genset> genset_(std::string letter_type);
65 
67  std::shared_ptr<context> context_();
68  std::shared_ptr<context> context_(std::string word);
69 
71  std::shared_ptr<ast_node> labelset_();
72  std::shared_ptr<ast_node> labelset_(const std::string& kind);
73 
75  std::shared_ptr<ast_node> weightset_();
76  std::shared_ptr<ast_node> weightset_(const std::string& ws);
77 
79  std::shared_ptr<automaton> automaton_();
80  std::shared_ptr<automaton> automaton_(std::string prefix);
81 
83  std::shared_ptr<tuple> tuple_();
84 
86  std::shared_ptr<tupleset> tupleset_();
87 
89  std::shared_ptr<expressionset> expressionset_();
91  std::shared_ptr<expressionset> seriesset_();
92 
94  std::shared_ptr<expansionset> expansionset_();
95 
97  std::shared_ptr<polynomialset> polynomialset_();
98 
100  std::shared_ptr<ast_node> labelset_or_weightset_();
101  std::shared_ptr<ast_node> labelset_or_weightset_(const std::string& kind);
103  std::istringstream& is_;
104 
106  std::set<std::string> weightsets_ =
107  {
108  "b",
109  "f2",
110  "log",
111  "nmin",
112  "q",
113  "qmp",
114  "r",
115  "rmin",
116  "z",
117  "zmin",
118  };
119 
121  std::set<std::string> labelsets_ =
122  {
123  "lal",
124  "lal_char",
125  "lan",
126  "lan_char",
127  "lao",
128  "law",
129  "law_char",
130  "letterset",
131  "nullableset",
132  "wordset",
133  };
134  };
135  }
136 }
context_parser(std::istringstream &is)
std::istringstream is
The input stream: the specification to translate.
Definition: translate.cc:380
std::string parameters_()
The next parameters in the stream.
std::shared_ptr< ast_node > labelset_()
.
std::shared_ptr< automaton > automaton_()
"\<" "\>".
char eat_(char c)
Accept this character, possibly preceded by spaces.
std::shared_ptr< tuple > tuple_()
"\<" ( ",")* "\>".
std::shared_ptr< expressionset > expressionset_()
"expressionset" "\<" "\>", possibly followed by identities.
std::shared_ptr< context > context_()
, .
std::shared_ptr< ast_node > parse_context()
Accept only a valid context.
std::shared_ptr< ast_node > labelset_or_weightset_()
|
void check_eof_(std::shared_ptr< ast_node > res)
We managed to read res in is, check that is_ is finished.
std::set< std::string > weightsets_
The set of terminal weightset names.
std::shared_ptr< ast_node > any_()
Accept anything.
std::shared_ptr< const genset > genset_()
An optional generator set in brackets (e.g., or ).
void skip_space_()
Skip white spaces.
std::shared_ptr< ast_node > parse()
Accept anything.
int peek_()
The next character, possibly preceded by spaces.
std::shared_ptr< polynomialset > polynomialset_()
"polynomialset" "\<" "\>".
std::shared_ptr< expansionset > expansionset_()
"expansionset" "\<" "\>".
std::istringstream & is_
The stream we are parsing.
std::set< std::string > labelsets_
The set of weightset names.
std::shared_ptr< ast_node > weightset_()
.
std::shared_ptr< expressionset > seriesset_()
No optional argument.
std::string word_()
The next word in the stream.
auto prefix(const Aut &aut) -> decltype(::vcsn::copy(aut))
Definition: prefix.hh:69
std::shared_ptr< tupleset > tupleset_()
"\<" ( | ",")+ "\>".
Definition: a-star.hh:8