Vcsn  2.1
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  std::shared_ptr<ast_node> any_();
31 
34  std::string word_();
35 
38  std::string parameters_();
39 
41  std::shared_ptr<const genset> genset_();
42  std::shared_ptr<const genset> genset_(std::string letter_type);
43 
45  std::shared_ptr<context> context_();
46  std::shared_ptr<context> context_(std::string word);
47 
49  std::shared_ptr<ast_node> labelset_();
50  std::shared_ptr<ast_node> labelset_(const std::string& kind);
51 
53  std::shared_ptr<ast_node> weightset_();
54  std::shared_ptr<ast_node> weightset_(const std::string& ws);
55 
57  std::shared_ptr<automaton> automaton_(std::string prefix);
58 
60  std::shared_ptr<tuple> tuple_();
61 
63  std::shared_ptr<tupleset> tupleset_();
64 
66  std::shared_ptr<expressionset> expressionset_();
68  std::shared_ptr<expressionset> seriesset_();
69 
71  std::shared_ptr<expansionset> expansionset_();
72 
74  std::shared_ptr<polynomialset> polynomialset_();
75 
77  std::shared_ptr<ast_node> labelset_or_weightset_();
78  std::shared_ptr<ast_node> labelset_or_weightset_(const std::string& kind);
80  std::istringstream& is_;
81 
83  std::set<std::string> weightsets_ =
84  {
85  "b",
86  "f2",
87  "log",
88  "nmin",
89  "q",
90  "qmp",
91  "r",
92  "rmin",
93  "z",
94  "zmin",
95  };
96 
98  std::set<std::string> labelsets_ =
99  {
100  "lal",
101  "lal_char",
102  "lan",
103  "lan_char",
104  "lao",
105  "law",
106  "law_char",
107  "letterset",
108  "nullableset",
109  "wordset",
110  };
111  };
112  }
113 }
std::shared_ptr< expressionset > expressionset_()
"expressionset" "\<" "\>", possibly followed by identities.
std::set< std::string > labelsets_
The set of weightset names.
std::shared_ptr< ast_node > labelset_or_weightset_()
|
std::shared_ptr< ast_node > any_()
Accept anything.
std::shared_ptr< const genset > genset_()
A generator set (e.g., char_letters(abc) or char).
std::shared_ptr< automaton > automaton_(std::string prefix)
"\<" "\>".
std::istringstream is
The input stream: the specification to translate.
Definition: translate.cc:372
std::shared_ptr< ast_node > parse_context()
Accept only a valid context.
std::string parameters_()
The next parameters in the stream.
std::shared_ptr< ast_node > labelset_()
.
std::shared_ptr< ast_node > weightset_()
.
std::set< std::string > weightsets_
The set of terminal weightset names.
std::shared_ptr< tuple > tuple_()
"\<" ( ",")* "\>".
std::shared_ptr< tupleset > tupleset_()
"\<" ( | ",")+ "\>".
std::shared_ptr< context > context_()
, .
std::shared_ptr< ast_node > parse()
Accept anything.
std::shared_ptr< expansionset > expansionset_()
"expansionset" "\<" "\>".
auto prefix(const Aut &aut) -> decltype(::vcsn::copy(aut))
Definition: prefix.hh:69
context_parser(std::istringstream &is)
std::shared_ptr< expressionset > seriesset_()
No optional argument.
std::shared_ptr< polynomialset > polynomialset_()
"polynomialset" "\<" "\>".
std::istringstream & is_
The stream we are parsing.
std::string word_()
The next word in the stream.