Separation of Grammar and Semantics
Unlike many other parsing libraries, Chevrotain is not limited 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.