IslandSytntax>>world
world := PPUnresolvedParser new.
world def: (island , world) / island / (water,world) / water.
^world.
Well --- this has nothing to do with your problem --- but you
shouldn't use #def: in subclasses of PPCompositeParser.
PPCompositeParser takes care and resolves recursive references for
you. So better just write:
IslandSyntax>>world
^ (island , world) / island / (water , world) / water
the inspector is called twice, probably because in the
"world" production
I first put (island , world) and then (island).
Is there a way to avoid this double calling?
Am I doing anything wrong here?
I am not sure what you are trying to achieve with this grammar. So it
is impossible for me to understand what the grammar is supposed to do.
Certainly both productions 'island' and 'water' will trigger the
inspector. The #not does not prevent the side effects its receiver
has.
I am sure that the PetitParser debugger can give you an explanation of
why the two examples parse different to what you expect.
Likely you need to adapt the grammar, or trigger the events after
parsing and resolving the duplicates.
If you are searching a random input stream for some part that
satisfies a grammar use #matchesIn:, #matchesIn:do:,
#matchingRangesIn:, or #matchingRangesIn:do:.
Lukas
--
Lukas Renggli
www.lukas-renggli.ch