Embedding sub-rules into the generated Rule enum #806
Louis-Proffit
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Similary to what is done in Menhir in OCaml and ANTLR for some targets, could you imagine embedding sub-rules inside the generated enum ? This would avoid the unnecessary interaction with the Pairs API.
For instance, a rule like pair = { ident~ ":" ~ value } would result in a generated enum of Rule::pair { ident:XXX, value:YYY} where XXX and YYY would be structs or enums representing the ident and value respectively.
This would probably need all rules to be mapped to a struct, and all rules with alternatives to be mapped to enums embedding other structs.
The benefit would be a full compile-time safety for our grammar, that the calls to into_inner(), next() and unwrap() of the current API does not provide.
Beta Was this translation helpful? Give feedback.
All reactions