CompositeParser initializes in constructor
eitch opened this issue · 4 comments
I would prefer it, if the CompositeParser would not call initialize in the constructor, as i want to override the constructor to pass in parameters in sub classes which are then used in the initialize method.
Do you have a suggestion in how to solve the problem? Lazy-initialization of the composite parser could work, but comes with many complications ...
Could you be more specific in why exactly you need to override the constructor? Maybe there is another solution?
Possibly the grammar definition approach in Dart could be backported to Java: https://github.com/petitparser/dart-petitparser/blob/master/lib/src/petitparser/definition.dart
Added GrammarDefinition
in f933653, which essentially works the same as CompositeGrammar, but the grammar can be defined anywhere/anywhow. To resolve everything .build()
has to be called to get the parser instance. This follows the implementation in Dart and should solve the problem you describe.
Thanks, i'll have a look at it and migrate to this.