Chevrotain
Home
Features
Tutorial
Guide
FAQ
Changes
APIs
Playground
Benchmark
Discussions
GitHub
Home
Features
Tutorial
Guide
FAQ
Changes
APIs
Playground
Benchmark
Discussions
GitHub
  • Features

    • Blazing Fast
    • LL(K) Grammars
    • Separation of Grammar and Semantics
    • Easy Debugging
    • Fault Tolerance
    • Multiple Start Rules
    • Customizable Error Messages
    • Parameterized Rules
    • Gates
    • Syntactic Content Assist
    • Grammar Inheritance
    • Backtracking
    • Syntax Diagrams
    • RegExp Based Lexers
    • Position Tracking
    • Token Alternative Matches
    • Token Skipping
    • Token Categories
    • Token Grouping
    • Custom Token Patterns
    • Lexer Modes

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.
Edit this page on GitHub
Last Updated: 6/27/22, 12:27 AM
Contributors: Shahar Soel, bd82
Prev
LL(K) Grammars
Next
Easy Debugging