patchExprScanner.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::scanner
28 
29 Description
30  Ragel lexer/scanner interface for patch expressions.
31 
32 Note
33  Ragel code generated with the ./createCode script.
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef expressions_patchExprScanner_H
38 #define expressions_patchExprScanner_H
39 
40 #include "exprScanToken.H"
41 #include "patchExprFwd.H"
42 
43 namespace Foam
44 {
45 namespace expressions
46 {
47 namespace patchExpr
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class scanner Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class 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 
82 public:
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(patchExpr::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 patchExpr
137 } // End namespace expressions
138 } // End namespace Foam
139 
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 #endif
144 
145 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::expressions::patchExpr::scanner::~scanner
~scanner()
Destructor, deletes parser.
patchExprFwd.H
Foam::expressions::patchExpr::scanner::process
bool process(const std::string &str, parseDriver &driver_)
Evaluate string.
Definition: patchExprScanner.H:126
Foam::expressions::patchExpr::scanner::scanner
scanner(bool withDebug=false)
Default construct, optionally setting debugging.
Definition: patchExprScanner.H:90
exprScanToken.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::expressions::patchExpr::parseDriver
Driver for patch expressions.
Definition: patchExprDriver.H:159
Foam::expressions::patchExpr::parser
Lemon parser interface for patch expressions grammar.
Definition: patchExprParser.H:50
Foam::expressions::patchExpr::scanner::process
bool process(const std::string &str, size_t pos, size_t len, parseDriver &driver_)
Evaluate sub-string.
Foam::expressions::patchExpr::scanner::debug
int debug
Local debugging.
Definition: patchExprScanner.H:84
Foam::expressions::patchExpr::scanner
Ragel lexer/scanner interface for patch expressions.
Definition: patchExprScanner.H:53
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:177