[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:

The lemon wrapper with m4 filtering:

The m4 macros used for lemon:

An example of m4-augmented lemon grammar:

The corresponding ragel scanner:

The expected tokens for the lemon parser are pre-built, which allows the 
rest of the code to build in parallel without issue.


More information about the ragel-users mailing list