On 27 Jul 2010, at 12:02, Alberto Bacchelli wrote:
In order to define a Java grammar in PetitParser, I am looking at how
PetitSmalltalk is implemented.
- Should a grammar like that of a programming language be
created as a subclass of PPCompositeParser? What's the advantage over
just a subclass of PPParser?
It offers a nice infrastructure to define the productions as methods
and reference them through instance variables.
Take the following example:
^ addition / factors
terms is a production that is defined in terms of two other
productions: addition and factors. These two productions are actually
instance variables in the PPArithmeticParser class and have
corresponding methods defining the productions. For example:
^ multiplication / power
- Unfortunately, I do not understand why PetitSmalltalk uses a
PPSmalltalkTokenParser instead of a normal "token".
The comment of PPSmalltalkTokenParser says:
A parser that knows how to skip comments and whitespace in Smalltalk
and how to instantiate tokens.
Moose-dev mailing list
"Value is always contextual."