Abstracting rule precedence #181
mikeaustin
started this conversation in
Show and tell
Replies: 1 comment
-
The thing that you implemented looks like a semi-generic solution for the template rules and if and when their will be implemented in the peggy it should solve your problem. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been using PEG.js on and off for years now, and I like the syntax and stability. One thing though is that it doesn't support left recursion, so all precedence-dependent rules are chained, which makes it difficult to re-arrange or remove rules. I recently experimented with simple precedence abstraction, so that rules can be defined independently of their precedence:
https://github.com/mikeaustin/kopi/blob/master/kopi4/src/rules.js
A trimmed down example below. I'm glad to see PEG.js revived. I feels it's the simplest and most straightforward PEG parser for JS.
Beta Was this translation helpful? Give feedback.
All reactions