I have experience writing parsers with ANTLR, and I'm trying (for self-education :)) to transfer one of them to PEG (grammar of the Parsing expression).
As I try to understand this idea, it seems cumbersome to me how much I feel I have missed something: How to deal with gaps.
In ANTLR, the normal way to deal with spaces and comments was to place markers in a hidden channel, but there is no tokenization step using PEG grammars. Given languages โโsuch as C or Java, where comments are allowed almost universally, one could immediately โhideโ comments, but since comments can have semantic meaning (for example, when creating code documentation, class diagrams, etc.), One doesnโt just wanted to drop them.
So is there a way to handle this?
parser-generator peg
Krumelur
source share