Pegase's AST and Visitor implementation is fine, but lacks a sufficiency of type information and rigor that would be useful for moderately large grammars. The new implementation done by this PR does a few things:
Updates the grammar in significant ways, amongst which is the ability to recognize expressions the previous version was unable to parse.
Implements a very pedantic typed AST. This expands pegase's singular Node type to a suite of (currently) ~40 classes. These have rigid structure and can be reasoned about much more consistently. These also play well with ts-pattern.
The Node/NodeLike helpers have been replaced by a suite of creator functions defined on a per-class basis, which directly map to applying the constructor of the target class to the passed parameters. These a very convenient, especially in testing. As pegase's $from/$to cruft is not carried over into the custom AST, the same functions used to generate nodes within the parser and visitors can be used in test cases. Much more convenient.
Implements a very pedantic Visitor hierarchy. These require a visit method per Node class. While this is syntactically more verbose than pegase's Visitor type, it has semantic benefit: each visit method is more likely to be passed an object that has a property structure that is safe to work with.
Scopes have been simplified; testing suggests the newer implementation is likely sufficient.
Pegase's AST and Visitor implementation is fine, but lacks a sufficiency of type information and rigor that would be useful for moderately large grammars. The new implementation done by this PR does a few things:
$from
/$to
cruft is not carried over into the custom AST, the same functions used to generate nodes within the parser and visitors can be used in test cases. Much more convenient.