patchExprParser.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::expressions::patchExpr::parser
28 
29 Description
30  Lemon parser interface for patch expressions grammar
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef expressions_patchExprParser_H
35 #define expressions_patchExprParser_H
36 
37 #include "patchExprFwd.H"
38 
39 namespace Foam
40 {
41 namespace expressions
42 {
43 namespace patchExpr
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class parser Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class parser
51 {
52  // Private Data
53 
54  //- Prompt for parser tracing
55  static constexpr const char* const prompt_ = "patchExpr:";
56 
57  //- The lemon parser (demand-driven)
58  void* lemon_;
59 
60 
61 public:
62 
63  //- Local object debugging
64  int debug;
65 
66 
67  // Constructors
68 
69  //- Construct null
70  parser() : lemon_(nullptr), debug(patchExpr::debug) {}
71 
72 
73  //- Destructor, deletes parser backend
74  ~parser()
75  {
76  stop();
77  }
78 
79 
80  // Static Member Functions
81 
82  //- Return the text name corresponding to the tokenId
83  static word tokenName(int tokenId);
84 
85  //- Print all token names
86  static void printTokenNames(Ostream& os);
87 
88  //- Print all rules
89  static void printRules(Ostream& os);
90 
91 
92  // Member Functions
93 
94  //- Start parsing, with the given driver context
95  void start(parseDriver& driver_);
96 
97  //- Stop parsing, freeing the allocated parser
98  void stop();
99 
100  //- Push token/value to parser
101  void parse(int tokenId, scanToken* tokenVal);
102 };
103 
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 
106 } // End namespace patchExpr
107 } // End namespace expressions
108 } // End namespace Foam
109 
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 #endif
114 
115 // ************************************************************************* //
Foam::expressions::patchExpr::parser::printRules
static void printRules(Ostream &os)
Print all rules.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
patchExprFwd.H
Foam::expressions::patchExpr::parser::stop
void stop()
Stop parsing, freeing the allocated parser.
Foam::expressions::patchExpr::parser::start
void start(parseDriver &driver_)
Start parsing, with the given driver context.
Foam::expressions::patchExpr::parser::printTokenNames
static void printTokenNames(Ostream &os)
Print all token names.
Foam::expressions::patchExpr::parser::parse
void parse(int tokenId, scanToken *tokenVal)
Push token/value to parser.
Foam::expressions::patchExpr::scanToken
Definition: patchExprScanner.H:53
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::expressions::patchExpr::parseDriver
Driver for patch expressions.
Definition: patchExprDriver.H:140
Foam::expressions::patchExpr::parser
Lemon parser interface for patch expressions grammar.
Definition: patchExprParser.H:49
Foam::expressions::patchExpr::parser::~parser
~parser()
Destructor, deletes parser backend.
Definition: patchExprParser.H:73
Foam::expressions::patchExpr::parser::tokenName
static word tokenName(int tokenId)
Return the text name corresponding to the tokenId.
Foam::expressions::patchExpr::parser::debug
int debug
Local object debugging.
Definition: patchExprParser.H:63
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::expressions::patchExpr::parser::parser
parser()
Construct null.
Definition: patchExprParser.H:69