3

私の知る限り、PetitParserは各インスタンス変数を同じ名前の本番メソッドで初期化します。initializeたとえば、カスタムインスタンス変数を追加してメソッドで初期化するにはどうすればよいですか?

4

1 に答える 1

3

サブクラスのクラス側メソッドをオーバーライドして#ignoredNames、PetitParserが触れない独自のインスタンス変数を追加できます。

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
于 2013-03-22T16:44:16.070 に答える