Closed azenla closed 8 years ago
Why do you think it is cumbersome? What exactly would you like to do?
In my experience, having every source element in a token that is also referenced from the AST is what most compilers I've seen do.
Now, if you do not want to use token and are only interested into the position of certain things, you could create your own "EpsilonParser" that always succeeds, never consumes anything, but returns the current position in the input stream (instead of null).
@renggli Ok, I'll try wrapping everything in a token :) It's just a little annoying tbh, if there was another way, that would be great. Something where I didn't have to make everything a token, but it just magically works. Maybe I expect too much :) I still love petitparser a lot :P
I have a large grammar, and I need to be able to track source code locations, however, it is very cumbersome, with the Token class. Do you have any suggestions or ideas for things to add the petitparser to make this easier?
This is my grammar: https://github.com/badger-lang/badger/blob/master/lib/src/parser/grammar.dart