fieldExprScanner.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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::expressions::fieldExpr::scanner
28
29Description
30 Ragel lexer/scanner interface for patch expressions.
31
32Note
33 Ragel code generated with the ./createCode script.
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef expressions_fieldExprScanner_H
38#define expressions_fieldExprScanner_H
39
40#include "fieldExprFwd.H"
41
42namespace Foam
43{
44namespace expressions
45{
46namespace fieldExpr
47{
48
49/*---------------------------------------------------------------------------*\
50 Class scanner Declaration
51\*---------------------------------------------------------------------------*/
53class scanner
54{
55 // Private Data
56
57 //- Wrapped lemon parser
58 parser* parser_;
59
60 //- Ragel code state, action
61 int cs, act;
62
63
64 // Private Member Functions
65
66 //- Dispatch .method to parser (if known) or Fatal
67 bool dispatch_method
68 (
69 const parseDriver& driver_,
70 word ident // Receives a copy
71 ) const;
72
73 //- Dispatch identifier to parser (if possible) or Fatal
74 bool dispatch_ident
75 (
76 const parseDriver& driver_,
77 word ident // Receives a copy
78 ) const;
79
80
81public:
82
83 //- Local debugging
84 int debug;
85
86
87 // Constructors
88
89 //- Default construct, optionally setting debugging
90 explicit scanner(bool withDebug = false)
91 :
92 parser_(nullptr),
93 debug(fieldExpr::debug)
94 {
95 if (withDebug)
96 {
97 debug |= 4;
98 }
99 }
100
101
102 //- Destructor, deletes parser
103 ~scanner();
104
105
106 // Member Functions
107
108 //- Evaluate sub-string
109 bool process
110 (
111 const std::string& str, size_t pos, size_t len,
112 parseDriver& driver_
113 );
114
115 //- Evaluate sub-string
116 bool process
117 (
118 const std::string& str, size_t pos,
119 parseDriver& driver_
120 )
121 {
122 return process(str, pos, std::string::npos, driver_);
123 }
124
125 //- Evaluate string
126 bool process(const std::string& str, parseDriver& driver_)
127 {
128 return process(str, 0, std::string::npos, driver_);
129 }
130};
131
132
133// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134
135} // End namespace fieldExpr
136} // End namespace expressions
137} // End namespace Foam
138
139
140// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141
142#endif
143
144// ************************************************************************* //
Driver for generic primitive field expressions.
Lemon parser interface for field expressions grammar.
Ragel lexer/scanner interface for patch expressions.
~scanner()
Destructor, deletes parser.
bool process(const std::string &str, size_t pos, size_t len, parseDriver &driver_)
Evaluate sub-string.
scanner(bool withDebug=false)
Default construct, optionally setting debugging.
bool process(const std::string &str, size_t pos, parseDriver &driver_)
Evaluate sub-string.
bool process(const std::string &str, parseDriver &driver_)
Evaluate string.
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
dimensionedScalar pos(const dimensionedScalar &ds)