ENH: unified some common parser static methods

COMP: delay evaluation of fieldToken enumeration types

- lazy evaluation at runTime instead of compile-time to make the code
  independent of initialization order.
  Otherwise triggers problems on gcc-4.8.5 on some systems where
  glibc is the same age, or older.
This commit is contained in:
Mark Olesen
2019-12-11 13:32:36 +01:00
parent 622808c7d0
commit eb4fec371a
27 changed files with 818 additions and 525 deletions

View File

@ -36,7 +36,7 @@ Description
} // %include
/*
* include[patchExprLemonParserMacros.m4]
* include patchExprLemonParserMacros.m4
*include(`patchExprLemonParserMacros.m4')dnl
!done in a comment since many editors have issues matching m4 quotes!
*/
@ -46,8 +46,9 @@ Description
#include "patchExprParser.H"
#include "patchExprScanner.H"
#include "unitConversion.H"
#include "error.H"
#include "volFields.H"
#include "error.H"
#include "IOmanip.H"
#include "exprOps.H"
#include "exprDriverOps.H"
#include "GeometricFieldOps.H"
@ -491,13 +492,21 @@ rule_faceToPoint(phfield, hfield)
// ************************************************************************* //
dnl/* Standard m4 quoting
changequote([`],['])dnl
dnl*/
/*
* include m4/lemon/parser-methods.m4
include([m4/lemon/parser-methods.m4])dnl
dnl Can revert to standard m4 quoting
dnl ... Or not changequote([`],['])dnl Revert to standard m4 quoting
*/
%code
{
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
parser_code_static_methods(Foam::expressions::patchExpr::parser)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::expressions::patchExpr::parser::stop()
@ -537,27 +546,6 @@ void Foam::expressions::patchExpr::parser::parse
}
Foam::word Foam::expressions::patchExpr::parser::nameOfToken
(
int tokenId
) const
{
#ifndef NDEBUG
if
(
tokenId > 0
&& unsigned(tokenId) < (sizeof(yyTokenName) / sizeof(char*))
)
{
return yyTokenName[tokenId];
}
return "<invalid>";
#else
return word();
#endif
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End of %code