Work on the tutorial is still in-flux...please click here to read the latest version online using github.

Comments and feedback on this tutorial are welcome using gitub issues.

This is not a tutorial on Antlr4 grammars, instead it starts from an existing JSON.g4 grammar and illustrates one practical way to use the antlr4ts tools. As antlr4ts becomes more stable, thsi project may evolve into a more useful npm module as well

Browser-based use of antlr4ts is not yet supported, but may be possible soon!

The project is intended to replace the built-in JSON support found in most JavaScript engines, or the highly portable json2.js. Instead of parsing JSON into plain-old JavaScript object, Antlr can produce a parse-tree complete with information about every token found, e.g. the text's position within a file. Antlr also supports several patterns processing the the tree, including listeners and visitors. As a result:

Error reporting (and recovery) can be better in Antlr-based parsers than some others.

A parse tree can be useful in tools that seek to transform javascript while preserving its formatting.