Grammar: A language for making languages

What is Grammar?

Grammar is a language for making languages.

Can you show me an example?

Below is some code written in Grammar to create a simple language called Panda.

pandaParser root catchAllParser expressionParser operatorCell enum + - intCell expressionParser cells operatorCell catchAllCellType intCell

The Grammar code can generate a parser that parses statements like + 1 2 5 10 and - 10 2.

What is a longer description?

Grammar is a Tree Language for generating parsers for other Tree Languages. The parsers not only allow parsing of those languages but also can include code written in a host language (such as Javascript) for compiling and/or runtime interpreting of these languages.

Can I try it online?

Yes! The Tree Language Designer is an online tool for writing Grammar code to build languages right in your browser.

Grammar Roadmap

The following major features are likely to be added to a future version of Grammar:

Import statements

Dependent Types

Union Cell Types

Pattern Matching


Positional Parsers

LSP Support

BNF Parsing

Upgrading to CodeMirror Version 6

Grammar Release Notes

Here's a list of the notable changes in Grammar:

6.0.0 2023-4-2

  • ⚠️ BREAKING:
    • instead of NodeTypeDefinitions ending in Node it is now ParserDefinitions ending in Parser
    • baseNodeType > baseParser
    • blobNode > blobParser
    • errorNode > errorParser
    • catchAllNodeType > catchAllParser

5.0.0 2023-3-30

  • 🎉 You can now add scoped line parsers inside other line parser definitions.
  • ⚠️ BREAKING: A lot of methods that were formerly getX() have been changed to getters like get x().

4.0.0 2023-3-28

  • 🎉 blank lines are now OK
  • 🎉 added // comments
  • ⚠️ BREAKING:
    • Removed todo comments. Use // todo instead
    • Removed tooling keyword. Use // tooling instead

View source