On 12/18/2013 11:27 AM, Goubier Thierry wrote:
Le 18/12/2013 11:15, Nicolas Anquetil a écrit :
ben there is nothing magic about PPCompositeParser, it is a parser like
all the other one
and if you call rules without consuming any input + have a loop in the
rule calls, then there will be a infinite loop
Yes and no. Some parsers can't handle left-recursion in rules (petit
parser? LL parsers can't), some parsers don't have any problem with
left recursion (LR parsers like SmaCC).
I meant PPCompositeParser within PetitParser
All parsers PPParsers behave more or less the same way when we come to this.
If other can't handle correctly left-recursion ther eis no reasonnable
reason to hope that PPCompositeParser composite parser will do.
Moreover, being a recursive descent parser, PetitParser naturally can't
handle left recursivity
In this case, you will need to convert the grammar to a right recursive
one, for example like this (which is more or less the same thing I believe):
ClassOrInterfaceType: ClassType "/ InterfaceType -- this option is
useless here as it is equal to ClassType"
ClassType: TypeDeclSpecifier
TypeDeclSpecifier: TypeName { . TypeDeclSpecifier }
TypeName: Identifier TypeArgumentsopt
InterfaceType: TypeDeclSpecifier, TypeArgumentsopt
Some of the rules are not really needed, but that way it sticks closer
to the reference grammar
nicolas
--
Nicolas Anquetil -- RMod research team (Inria)