Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_regex.hpp
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_REGEX_HPP
11 #define TEUCHOS_REGEX_HPP
12 
13 #include <Teuchos_Language.hpp>
14 #include <Teuchos_FiniteAutomaton.hpp>
15 #include <Teuchos_ReaderTables.hpp>
16 #include <Teuchos_Reader.hpp>
17 
18 namespace Teuchos {
19 namespace regex {
20 
21 enum {
22  PROD_REGEX,
23  PROD_UNION_DECAY,
24  PROD_UNION,
25  PROD_CONCAT_DECAY,
26  PROD_CONCAT,
27  PROD_QUAL_DECAY,
28  PROD_STAR,
29  PROD_PLUS,
30  PROD_MAYBE,
31  PROD_SINGLE_CHAR,
32  PROD_ANY,
33  PROD_SINGLE_SET,
34  PROD_PARENS_UNION,
35  PROD_SET_POSITIVE,
36  PROD_SET_NEGATIVE,
37  PROD_POSITIVE_SET,
38  PROD_NEGATIVE_SET,
39  PROD_SET_ITEMS_DECAY,
40  PROD_SET_ITEMS_ADD,
41  PROD_SET_ITEM_CHAR,
42  PROD_SET_ITEM_RANGE,
43  PROD_RANGE
44 };
45 
46 enum { NPRODS = PROD_RANGE + 1 };
47 
48 enum {
49  TOK_CHAR,
50  TOK_DOT,
51  TOK_LRANGE,
52  TOK_RRANGE,
53  TOK_LPAREN,
54  TOK_RPAREN,
55  TOK_UNION,
56  TOK_RANGE,
57  TOK_NEGATE,
58  TOK_STAR,
59  TOK_PLUS,
60  TOK_MAYBE
61 };
62 
63 enum { NTOKS = TOK_MAYBE + 1 };
64 
65 Language make_language();
66 LanguagePtr ask_language();
67 
68 void make_lexer(FiniteAutomaton& result);
69 
70 ReaderTablesPtr ask_reader_tables();
71 
72 void make_dfa(FiniteAutomaton& result, std::string const& name, std::string const& regex, int token);
73 
74 class Reader : public Teuchos::Reader {
75  public:
76  Reader(int result_token_in);
77  virtual ~Reader() {}
78  protected:
79  virtual void at_shift(any& result, int token, std::string& text);
80  virtual void at_reduce(any& result, int token, std::vector<any>& rhs);
81  private:
82  int result_token;
83 };
84 
85 } // end namespace regex
86 } // end namespace Teuchos
87 
88 #endif
Reader(ReaderTablesPtr tables_in)
Constructor: accepts an RCP to ReaderTables.
void make_lexer(FiniteAutomaton &result, Language const &language)
construct a lexer for the Language tokens.
The main class for users to read text using TeuchosParser.
Declares Teuchos::ReaderTables.
RCP< const ReaderTables > ReaderTablesPtr
an RCP to a const ReaderTables
RCP< const Language > LanguagePtr
an RCP to a const Language
Declares Teuchos::Language.
Declares Teuchos::Reader.