Teuchos - Trilinos Tools Package
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
parser
src
Teuchos_Parser.hpp
Go to the documentation of this file.
1
// @HEADER
2
// *****************************************************************************
3
// Teuchos: Common Tools Package
4
//
5
// Copyright 2004 NTESS and the Teuchos contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef TEUCHOS_PARSER_HPP
11
#define TEUCHOS_PARSER_HPP
12
16
17
#include <Teuchos_TableDecl.hpp>
18
#include <Teuchos_Grammar.hpp>
19
20
namespace
Teuchos
{
21
22
enum
ActionKind {
23
ACTION_NONE,
24
ACTION_SHIFT,
25
ACTION_REDUCE
26
};
27
28
struct
Action {
29
ActionKind kind;
30
union
{
31
int
production;
32
int
next_state;
33
};
34
};
35
36
#ifdef HAVE_TEUCHOSCORE_CXX11
37
extern
template
struct
Table<Action>;
38
#endif
39
40
struct
Parser {
41
GrammarPtr grammar;
42
/* (state x terminal) -> action */
43
Table<Action> terminal_table;
44
/* (state x non-terminal) -> new state */
45
Table<int> nonterminal_table;
46
Parser() {}
47
Parser(GrammarPtr g,
int
nstates_reserve);
48
};
49
50
int
add_state(Parser& p);
51
int
get_nstates(Parser
const
& p);
52
void
add_terminal_action(Parser& p,
int
state,
int
terminal, Action action);
53
void
add_nonterminal_action(Parser& p,
int
state,
int
nonterminal,
int
next_state);
54
Action
const
& get_action(Parser
const
& p,
int
state,
int
terminal);
55
int
execute_action(Parser
const
& p, std::vector<int>& stack, Action
const
& action);
56
GrammarPtr
const
& get_grammar(Parser
const
& p);
57
73
class
ParserFail:
public
std::invalid_argument {
74
public
:
75
ParserFail(
const
std::string& msg);
76
};
77
103
Parser
make_lalr1_parser
(GrammarPtr grammar,
bool
verbose =
false
);
104
105
}
106
107
#endif
Teuchos
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
Teuchos::make_lalr1_parser
Parser make_lalr1_parser(GrammarPtr grammar, bool verbose)
Tries to create LALR(1) parser tables for a given grammar.
Definition
Teuchos_make_lalr1_parser.cpp:1233
Generated by
1.17.0