PetitParser crash

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

PetitParser crash

Sean P. DeNigris
Administrator
The "optional" below crashes my Pharo 1.2.2 image, and user interrupt has no effect...

categoryName := $- asParser negate plus flatten, ($- asParser, #any asParser star flatten) optional star.
categoryName parse: 'SuperMe'.

Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: PetitParser crash

Lukas Renggli
This is a bug in your parser, causing a direct recursion with "optional star".

Also this is a bug in Pharo causing direct recursion to hang the image.

#optional is a parser that always succeeds. #star is an parser that
parsers 0 or more times eagerly. Thus #star loops forever.

Thus, you should remove the #optional parser in your grammar, #star
alone already makes the receiver optional.

Lukas

On 7 August 2011 18:08, Sean P. DeNigris <[hidden email]> wrote:

> The "optional" below crashes my Pharo 1.2.2 image, and user interrupt has no
> effect...
>
> categoryName := $- asParser negate plus flatten, ($- asParser, #any asParser
> star flatten) optional star.
> categoryName parse: 'SuperMe'.
>
> Sean
>
> --
> View this message in context: http://forum.world.st/PetitParser-crash-tp3725129p3725129.html
> Sent from the Moose mailing list archive at Nabble.com.
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>



--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: PetitParser crash

Sean P. DeNigris
Administrator
Lukas Renggli wrote
Also this is a bug in Pharo causing direct recursion to hang the image.
I'll report it.

Lukas Renggli wrote
#optional is a parser that always succeeds. #star is an parser that
parsers 0 or more times eagerly. Thus #star loops forever.
Thanks, so "optional" is like the ? in other regex systems, meaning 0 or 1 times.
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: PetitParser crash

Lukas Renggli
>> #optional is a parser that always succeeds. #star is an parser that
>> parsers 0 or more times eagerly. Thus #star loops forever.
>>
> Thanks, so "optional" is like the ? in other regex systems, meaning 0 or 1
> times.

Yes, 'x?*' is illegal in most regex engines. I guess PetitParser could
also try to prevent it, at least in simple cases.

Lukas

--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.iam.unibe.ch/mailman/listinfo/moose-dev