Closed enjoysmath closed 1 year ago
On second thought, according to: https://github.com/PhilippeSigaud/Pegged/wiki/Grammar-Composition
I don't think I'd even have to re-combine them into a single grammar.
On second thought, according to: https://github.com/PhilippeSigaud/Pegged/wiki/Grammar-Composition
Indeed, that is what you are looking for.
I plan on making a grammar that is at least 1000 lines and managing / debugging such a thing will be difficult. But if I could split it up into multiple enums, one for each class of a thing that I wish to parse into, sort of like how some Python parser generators work, then I think the problem will be more feasible to solve. So I was just wondering if there were a way to do this. I would only do this if I can re-use existing grammars from other classes, as the things I'm parsing into are a somewhat of a hierarchy of types that will often depend on one another.
Is this possible with pegged? Why or why not.
I will try some things today. Of couse I should combine all the grammars into one, making sure I'm not duplicating any rules, as that would throw an error. The order in which I combine (concatenate) the grammar string will have to be manually sorted. But I'm fine with that.