Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom instance variables and initializing with PetitParser

As far as I know PetitParser initializes each instance variable with a production method of the same name. What should one do, to add a custom instance variable and initialize it in the initialize method for example?

like image 204
Uko Avatar asked Sep 15 '26 11:09

Uko


1 Answers

You can override the class-side method #ignoredNames in subclasses to add your own instance-variables that PetitParser does not touch:

PPCompositeParser class>>#ignoredNames
    "Answer a collection of instance-variables that should 
     not be automatically initialized with productions, but
     that are used internal to the composite parser."

     ^ PPCompositeParser allInstVarNames
like image 169
Lukas Renggli Avatar answered Sep 20 '26 03:09

Lukas Renggli