Closed doppio closed 3 years ago
This is a great idea, and a natural generalization of taking the grammar definition out of the Parser hierarchy (in one of the past versions). Looking into this right away ...
This will be part of petitparser 4.2.0.
Would you consider moving the ref (and possibly build/resolve) functions out of the GrammarDefinition class to promote them to top-level functions?
I have a series of complex parsers that I have broken up across files for simplicity and organization. To be able to conveniently use References, I would need all of my parser functions to wrapped in subclasses of GrammarDefinition. This would make the code a lot more verbose (almost unreadable) since every reference to a parser function would go from
ref0(parserFunction)
to something likeref0(subparserGrammar.parserFunction)
, assuming that parserFunction itself needs to contain references.Other thoughts on how to solve this would be appreciated. It would be nice to be able to define grammars across files to keep the code more organized. :)