-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
consider making Grammar a hashmap #166
Comments
I think this is a fair point about |
can't multiple |
I think yes it is semantically equivalent, but then in order to track which was used for parsing input, it is easier to use:
compared to:
maybe silly reason but it certainly helps me when reasoning about the parser. also another maybe silly reason, but someday I hope to have an API that supports user provided constructors for parse nodes, which having only one let my_parser = Grammer::new([
("<start> ::= 'a' 'b'", UserDefinedStart::from_a_and_b),
("<start> ::= 'c' 'd'", UserDefinedStart::from_c_and_d),
]);
// then use that parser
let parsed : UserDefinedStart = my_parser.parse("cd").next().unwrap(); |
couldn't we just do what we're doing now, using the normalized version for parsing but not exposing it to the user? if they give us |
though know that i say that i realize it makes decomposing productions the same way u might compose them impossible |
not sure if that's a compelling enough use case though, u can still decompose productions easily enough so long as they're normalized in the first place |
Having
Grammar
be a simple list of productions is elegant enough, but it doesn't really model the structure of a BNF grammar properly since there's nothing in it's structure explicitly connecting the nonterminals on the right to the nonterminals on the left, makingGrammar
ahashmap<Term, Vec<Expression>>
would allow users to traverse grammars out of the box and be a good middle-ground between the current flat grammars and a fully connected approach.i'm still uncertain about this idea and it's relatively low priority for now, in the meantime any feedback would be appreciated.
The text was updated successfully, but these errors were encountered: