CertainLach / jrsonnet

Rust implementation of Jsonnet language
MIT License
304 stars 33 forks source link

refactor: switch to nom-based parser #173

Open CertainLach opened 3 months ago

CertainLach commented 3 months ago

I want to use some code analysis for the optimizations for a long time, but peg-based parser is not flexible enough for that. While the long-term plan is to finish rowan parser, I still want to have a faster alternative parser for AST (Rowan is best for CST). In this PR, I have replaced peg-based parser with nom-based rewrite, and created a prototype analyzer, on which logic the real one will be based.

Commits will be split, some changed will be split into other PRs too, this is just a draft/PoC.

This parser also allows to quickier experimentation on language features, better syntax feature-gating (which was lacking for null-coalesce/destruction), better control over AST structures layout (I like the expression structure from rowan-based parser better, and this PR brings it partially).

It also implements numberic separators as proposed here: https://github.com/google/jsonnet/issues/1155, but I'll probably port this to peg in the meantime.

CertainLach commented 3 months ago

TODO: