omega_h
Reliable mesh adaptation
Omega_h_grammar.hpp
1 #ifndef OMEGA_H_GRAMMAR_HPP
2 #define OMEGA_H_GRAMMAR_HPP
3 
4 #include <memory>
5 #include <string>
6 #include <vector>
7 
8 namespace Omega_h {
9 
10 /* convention: symbols are numbered with all
11  terminal symbols first, all non-terminal symbols after */
12 
13 struct Grammar {
14  using RHS = std::vector<int>;
15  struct Production {
16  int lhs;
17  RHS rhs;
18  };
19  using Productions = std::vector<Production>;
20  int nsymbols;
21  int nterminals;
22  Productions productions;
23  std::vector<std::string> symbol_names;
24 };
25 
26 using GrammarPtr = std::shared_ptr<Grammar const>;
27 
28 int get_nnonterminals(Grammar const& g);
29 bool is_terminal(Grammar const& g, int symbol);
30 bool is_nonterminal(Grammar const& g, int symbol);
31 int as_nonterminal(Grammar const& g, int symbol);
32 int find_goal_symbol(Grammar const& g);
33 void add_end_terminal(Grammar& g);
34 int get_end_terminal(Grammar const& g);
35 void add_accept_production(Grammar& g);
36 int get_accept_production(Grammar const& g);
37 int get_accept_nonterminal(Grammar const& g);
38 
39 std::ostream& operator<<(std::ostream& os, Grammar const& g);
40 
41 } // namespace Omega_h
42 
43 #endif
Definition: amr_mpi_test.cpp:6
Definition: Omega_h_grammar.hpp:15
Definition: Omega_h_grammar.hpp:13