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-2021 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 "exprScanToken.H"
38 #include "patchExprFwd.H"
39 
40 namespace Foam
41 {
42 namespace expressions
43 {
44 namespace patchExpr
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class parser Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class parser
52 {
53  // Private Data
54 
55  //- Prompt for parser tracing
56  static constexpr const char* const prompt_ = "patchExpr:";
57 
58  //- The lemon parser (demand-driven)
59  void* lemon_;
60 
61 
62 public:
63 
64  //- Local object debugging
65  int debug;
66 
67 
68  // Constructors
69 
70  //- Construct null
71  parser() : lemon_(nullptr), debug(patchExpr::debug) {}
72 
73 
74  //- Destructor, deletes parser backend
75  ~parser()
76  {
77  stop();
78  }
79 
80 
81  // Static Member Functions
82 
83  //- Return the text name corresponding to the tokenId
84  static word tokenName(int tokenId);
85 
86  //- Print all token names
87  static void printTokenNames(Ostream& os);
88 
89  //- Print all rules
90  static void printRules(Ostream& os);
91 
92 
93  // Member Functions
94 
95  //- Start parsing, with the given driver context
96  void start(parseDriver& driver_);
97 
98  //- Stop parsing, freeing the allocated parser
99  void stop();
100 
101  //- Push token type to parser with default token
102  void parse(int tokenId);
103 
104  //- Push token type/value to parser
105  void parse(int tokenId, scanToken tok);
106 };
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 } // End namespace patchExpr
111 } // End namespace expressions
112 } // End namespace Foam
113 
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 #endif
118 
119 // ************************************************************************* //
Driver for patch expressions.
static word tokenName(int tokenId)
Return the text name corresponding to the tokenId.
void start(parseDriver &driver_)
Start parsing, with the given driver context.
int debug
Local object debugging.
A low-level input/scan token content. No defined constructors/destructors. All memory management is m...
Definition: exprScanToken.H:47
~parser()
Destructor, deletes parser backend.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Lemon parser interface for patch expressions grammar.
void parse(int tokenId)
Push token type to parser with default token.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
static void printRules(Ostream &os)
Print all rules.
void stop()
Stop parsing, freeing the allocated parser.
Namespace for OpenFOAM.
static void printTokenNames(Ostream &os)
Print all token names.