toml-node icon indicating copy to clipboard operation
toml-node copied to clipboard

Suggestion: A new infrastructure for this Toml -> Json compiler

Open bd82 opened this issue 5 years ago • 0 comments

Hello @BinaryMuse and other contributors 😄

Context

I am creating a set of re-usable and modular Toml related tooling in here.

One of the first modules is a Toml to Syntax Tree parser.

How this could benefit the Toml-Node project

The Toml to Concrete Syntax Tree parser could be evaluated for re-use as the parser for this repo's Toml to Json compiler. So instead of implementing both a parser and a compiler in this repo. Toml-Node would only implement a (to Json) compiler using a Syntax Tree Visitor.

Pros

  • Let someone else deal with aligning to the specifications 😄 .
  • Toml 0.5 support.
    • Will solve #50
  • I estimate (potential) for around two orders of magnitude higher performance than Toml-Node.
  • Try out the benchmark.
  • Just an estimate, Depends on how complex the compiler is relative to parsing...
  • Will solve #39

Cons

  • Early work, expect some bugs.
    • But those should be ironed out quickly as the Toml spec is very simple.
  • Larger library size (including deps) as the Chevrotain Parsing Toolkit runtime used is: 146K/B minified.
  • No Streaming support (yet).
    • Will hopefully exist at a later time (but likely not soon).
  • No longer a dependency free library.
  • Bundling of Chevrotain based parsers must be done carefully due to reliance on Function.prototype.toString.
    • but this can be fully mitigated transparently from end users.

Summary

This has a potential to improve both the performance and alignment to newest spec of Toml Node, but with the cons described above.

@BinaryMuse could this be of interest to Toml Node?

Cheers. Shahar.

bd82 avatar Jan 28 '19 20:01 bd82