- PPParser>>matchList* do never refer to self
(but to call themselves
recursively).
This looks correct to me. This is to recurse into the graph of parsers.
Because these methods do not refer to self, they could be implemented
in a different class to avoid cluttering the already large PPParser. I
think Kent Beck is talking about that in the Best Practice Patterns
:-)
Yes, but I prefer to have things that work together at the same place.
- Why is #def: not defined in PPUnresolvedParser? You
implemented it
in PPParser. It might be useful for other parsers, but do you have an
example?
PPParser is a superclass of PPUnresolvedParser, therefore you can send
#def: to any instance of PPUnresolvedParser.
Sure. But why did you put #def: in PPParser and not directly in
PPUnresolvedParser?
It makes sense on other parsers too.
I would like to get rid of #def: and PPUnresolvedParser. Do not use them.
For example, what is the meaning of
#digit asParser star def: #letter asParser
?
PPUnresolvedParser new def: #letter asParser
has no meaning in the same way your example has no meaning. #def: only
makes sense on a parser instances that are referred to elsewhere (look
at the examples in the tests). Again, there are better ways to do the
same without using the H-bomb of Smalltalk (#def: is a #become:). It
made sense in the beginning of PetitParser, but it is not longer much
useful today.
Lukas
--
Lukas Renggli
www.lukas-renggli.ch