Please ask further questions in the Moose mailing-list, other people
might be interested too.
> I'm trying to understand how PetitParser initializes grammar classes (the
> tutorial doesn't make it clear how to use def: in a class context). I see
> now that mutual recursive productions should work out of the box.
You don't need #def: in the context of PPCompositeParser, the
framework does that for you. See the class comment of
PPCompositeParser for additional information.
> However, while figuring this out, I noticed this following bit:
> parser := PPUnresolvedParser named: aSymbol.
> productionIndexesAndNames do: [ :assoc |
> self instVarAt: assoc key put: (PPUnresolvedParser named:
> assoc value) ].
> parser := self perform: aSymbol.
> It seems that the last line of the snippet should read:
> parser def: (self perform: aSymbol).
Yes, you are right. I changed that in the latest version.
However, consider not to loop into the start state. You get a more
reusable model if you use 'parser' simply as a selector of where to
start the grammar (e.g. the method, the method declaration, or the
expression in the example of Smalltalk).
> This would be consistent with how the rest of the productions initialize
> themselves and wouldn't make the first line of the snippet pointless.
> I can't really discern any difference in commenting out line one, leaving
> everything as is, or shifting the last bit to def: So I'm missing something!