Conversation
|
@pragmaticpandy Thanks a lot for looking into it! I like the idea overall, but what actually bothers me is that anonymous tokens (or tokens collected from the grammar's parsers in general) are ordered implicitly. When the set of tokens is ambiguous, their order matters, and the easiest way to order tokens in the way you want is to declare them explicitly so that the precedence comes from the order of declaration. What do you think about sorting the anonymous (parser-provided) tokens by their enclosing parsers order? I mean, if an anonymous token is declared and used in a parser that goes in a grammar before another parser, then this token takes precedence over the other parser's anonymous tokens? I'm not sure this kind of ordering is intuitive enough, but I'd say it's a bit more intuitive than ordering the tokens by their occurrences in the nested, complex parser structure. I also think about experimenting with token-less parsing, where a |
|
@h0tk3y re: Tokenless parsers |
|
Apologies for abandoning this PR for so long. Totally agree on explicit declaration being most clear. I was burned on this issue again today because I tried to use something like the following: Then, I was confused for a while when I got a What I really want is to have not been confused by such a situation; I have been at least twice now. My original draft PR suggests dealing with this by supporting anonymous tokens, but perhaps a better solution is simply to detect any anonymous tokens, and throw an exception that explains the situation and prompts the user to add explicit token declarations. |
Work in progress; haven't fixed all the tests yet. Threw this together and wanted to confirm you are interested in the patch and get any other feedback before I spend more time on it.
See changes to the readme and
OrTestto get a quick idea how this changes the public API.#36