[ragel-users] combining ragel and lemon (update)
Mark Olesen
Mark.Olesen at esi-group.com
Mon Jan 13 07:47:08 EST 2020
I figured that I should provide a followup on this topic.
OpenFOAM-v1912 (Dec 2019 release) now includes expression evaluation
using a combination of ragel and lemon - my thanks to Adrian for a few
pointers regarding simplifying my use of ragel.
You could say that the OpenFOAM expressions are essentially a glorified
calculator, except that we handle various vector-space fields
(scalar/vector/tensor/symmTenor/sphericalTensor) for internal meshes and
patch fields etc.
The scanner is ragel, the parser is a version of lemon that has been
minimally modified to allow for C++ namespaces - to allow for good
encapsulation without forcing any particular interface on the user or
affecting the use of lemon for C-code. To managing the large number of
similar definitions, the lemon grammar is modularized using m4 macros.
Here are some code references as of Jan-2020:
The m4-augmented lemon make rules:
https://develop.openfoam.com/Development/openfoam/blob/master/wmake/rules/General/lemon
The lemon wrapper with m4 filtering:
https://develop.openfoam.com/Development/openfoam/blob/master/wmake/scripts/wrap-lemon
The m4 macros used for lemon:
https://develop.openfoam.com/Development/openfoam/tree/master/src/OpenFOAM/include/m4/lemon
An example of m4-augmented lemon grammar:
https://develop.openfoam.com/Development/openfoam/blob/master/src/OpenFOAM/expressions/fields/fieldExprLemonParser.lyy-m4
The corresponding ragel scanner:
https://develop.openfoam.com/Development/openfoam/blob/master/src/OpenFOAM/expressions/fields/fieldExprScanner.rl
The expected tokens for the lemon parser are pre-built, which allows the
rest of the code to build in parallel without issue.
Cheers,
/mark
More information about the ragel-users
mailing list