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