Separation of Grammar and Semantics
Chevrotain is not limited like many other parsing libraries to only embedding actions inside the grammar, It can also automatically create a Concrete Syntax Tree Which can later be traversed using the visitor pattern.
This implements the design principle of Separation of Concerns which enables re-use of the same pure grammar for multiple purposes.
See example of two identical mathematical expression grammars:
- Firstly using embedded actions for semantics.
- Secondly using Separated semantics with a CST Visitor.