Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_Language.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_LANGUAGE_HPP
11#define TEUCHOS_LANGUAGE_HPP
12
17#include <string>
18#include <vector>
19#include <iosfwd>
20
21#include <Teuchos_Grammar.hpp>
22#include <Teuchos_FiniteAutomaton.hpp>
24#include <Teuchos_RCP.hpp>
25
26namespace Teuchos {
27
28
120struct Language {
121 struct Token {
122 std::string name;
123 std::string regex;
124 void operator()(std::string const& name_in, std::string const& regex_in);
125 };
126 typedef std::vector<Token> Tokens;
128 Tokens tokens;
129 typedef std::vector<std::string> RHS;
130 struct Production;
131 struct RHSBuilder {
132 Production& prod;
133 RHSBuilder(Production& prod_in);
134 RHSBuilder& operator,(std::string const& rhs_item);
135 RHSBuilder& operator>>(std::string const& rhs_item);
136 };
137 struct Production {
138 std::string lhs;
139 RHS rhs;
140 RHSBuilder operator()(std::string const& lhs_in);
141 };
142 typedef std::vector<Production> Productions;
144 Productions productions;
145};
146
149
150GrammarPtr make_grammar(Language const& language);
151
162void make_lexer(FiniteAutomaton& result, Language const& language);
163
164
170
171std::ostream& operator<<(std::ostream& os, Language const& lang);
172
173}
174
175#endif
Reference-counted pointer class and non-member templated function implementations.
Declares Teuchos::ReaderTables.
Smart reference counting pointer class for automatic garbage collection.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
void make_lexer(FiniteAutomaton &result, Language const &language)
construct a lexer for the Language tokens.
RCP< const Language > LanguagePtr
an RCP to a const Language
ReaderTablesPtr make_reader_tables(Language const &language)
constructs ReaderTables for the given Language.
The main class for users to define a language using TeuchosParser.
Productions productions
vector of productions
Tokens tokens
vector of tokens