antlr4ts-json

1.0.0 • Public • Published

antlr4ts-json - Yet another JSON parser

This is a tutorial for using antlr4ts & antlr4ts-clito use Antlr4 grammars on Node.js (using TypeScript). It is based on the JSON-based language beacuse this it is well understood in the JavaScript community.

  • 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!

Pre-release notes: Why someone would build another JSON parser in JavaScript

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.

/antlr4ts-json/

    Package Sidebar

    Install

    npm i antlr4ts-json

    Weekly Downloads

    0

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • burt_harris