Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_make_lalr1_parser.hpp
1#ifndef TEUCHOS_BUILD_PARSER_HPP
2#define TEUCHOS_BUILD_PARSER_HPP
3
4#include <set>
5#include <memory>
6
7#include <Teuchos_Parser.hpp>
8#include <Teuchos_Graph.hpp>
9#include <Teuchos_RCP.hpp>
10
11namespace Teuchos {
12
13struct Config {
14 int production;
15 int dot;
16 Config(int p, int d);
17};
18
19typedef std::vector<Config> Configs;
20
21typedef std::set<int> Context;
22
23/* nonterminal transitions will be stored as SHIFT
24 actions while in progress */
25struct ActionInProgress {
26 Action action;
27 Context context;
28};
29
30struct StateInProgress {
31 std::vector<int> configs;
32 typedef std::vector<ActionInProgress> Actions;
33 Actions actions;
34};
35
36void swap(StateInProgress& a, StateInProgress& b);
37
38typedef RCP<StateInProgress> StateInProgressPtr;
39
40typedef std::vector<StateInProgressPtr> StatesInProgress;
41
42struct StateConfig {
43 int state;
44 int config_in_state;
45 StateConfig(int s, int cis);
46};
47
48typedef std::vector<StateConfig> StateConfigs;
49
50struct ParserInProgress {
51 StatesInProgress states;
52 Configs configs;
53 StateConfigs state_configs;
54 Graph states2state_configs;
55 GrammarPtr grammar;
56};
57
58StateConfigs form_state_configs(StatesInProgress const& states);
59Graph form_states_to_state_configs(StateConfigs const& scs,
60 StatesInProgress const& states);
61
62void print_graphviz(
63 std::string const& filepath,
64 ParserInProgress const& pip,
65 bool verbose,
66 std::ostream& os
67 );
68
69ParserInProgress draft_lalr1_parser(GrammarPtr grammar, bool verbose = false);
70
71Parser accept_parser(ParserInProgress const& pip);
72
73class ParserBuildFail: public std::invalid_argument {
74 public:
75 ParserBuildFail(const std::string& msg);
76};
77
78}
79
80#endif
Declares Teuchos::Parser, ParserFail and make_lalr1_parser.
Reference-counted pointer class and non-member templated function implementations.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...