Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
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>
16#include <Teuchos_Reader.hpp>
17
18namespace Teuchos {
19namespace regex {
20
21enum {
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
46enum { NPRODS = PROD_RANGE + 1 };
47
48enum {
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
63enum { NTOKS = TOK_MAYBE + 1 };
64
65Language make_language();
66LanguagePtr ask_language();
67
68void make_lexer(FiniteAutomaton& result);
69
70ReaderTablesPtr ask_reader_tables();
71
72void make_dfa(FiniteAutomaton& result, std::string const& name, std::string const& regex, int token);
73
74class 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
Declares Teuchos::Language.
Declares Teuchos::ReaderTables.
Declares Teuchos::Reader.
The main class for users to read text using TeuchosParser.
Reader(ReaderTablesPtr tables_in)
Constructor: accepts an RCP to ReaderTables.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
RCP< const ReaderTables > ReaderTablesPtr
an RCP to a const ReaderTables
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