Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
23 #include <Teuchos_ReaderTables.hpp>
24 #include <Teuchos_RCP.hpp>
25 
26 namespace Teuchos {
27 
28 
120 struct 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 
150 GrammarPtr make_grammar(Language const& language);
151 
162 void make_lexer(FiniteAutomaton& result, Language const& language);
163 
164 
170 
171 std::ostream& operator<<(std::ostream& os, Language const& lang);
172 
173 }
174 
175 #endif
Productions productions
vector of productions
The main class for users to define a language using TeuchosParser.
void make_lexer(FiniteAutomaton &result, Language const &language)
construct a lexer for the Language tokens.
Declares Teuchos::ReaderTables.
Tokens tokens
vector of tokens
ReaderTablesPtr make_reader_tables(Language const &language)
constructs ReaderTables for the given Language.
RCP< const Language > LanguagePtr
an RCP to a const Language
Smart reference counting pointer class for automatic garbage collection.
Reference-counted pointer class and non-member templated function implementations.