Teuchos: proposal for TeuchosParser subpackage
Created by: ibaned
The purpose of TeuchosParser would be to provide a C++ library which takes a language described by a Context Free Grammar and a set of tokens described by Regular Expressions, and generates a table-driven LALR(1) parser for this language. The parser takes the form of a C++ base class with virtual functions that users override to provide callbacks at each parsing step, allowing users to focus on how to interpret the language constructs, not how to interpret the text file.
Immediate benefits of TeuchosParser would be:
-
Applications often want users to be able to specify boundary and initial conditions with arbitrary mathematical expressions in strings. Currently two pieces of Trilinos code enable this:
- The "runtime compiler" in Pamgen
- The STKExprEval sub-package
Both of these packages have hand-coded parsers. TeuchosParser could provide their parsing infrastructure, leaving these packages free to focus on the execution of the expressions themselves.
-
The Teuchos XML parser, also hand-coded, could be replaced with a call to TeuchosParser, with callbacks to build the Teuchos ParameterList.
-
The Teuchos YAML parser could be refactored to not rely on
yaml-cpp
, and use TeuchosParser instead. TPLs in general have the disadvantage of being less readily available on all platforms compared to Trilinos packages.yaml-cpp
in particular makes excessive use of exceptions during normal operation and has been slow to release new versions. -
Trilinos packages and applications that use Trilinos would have a much lower barrier to defining their own languages, possibly dynamically at runtime, without creating yet another hand-coded parser.
I already have prototype code ready to provide the core of this functionality, what remains to be done is some technical cleanup followed by the integrations above. I've discussed with @jgfouca and @bartlettroscoe who so far approve of this idea.
@trilinos/teuchos