Re: PetitParser - some questions

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

Re: PetitParser - some questions

Lukas Renggli
I redirect this to the moose list, please as there or in the pharo
list in the future.

> One thing I've noticed is the error messages (PPFailure). I like that
> it tells you what is wrong and where.  What I don't like is how it
> decides to tell you that.

This can be customized.

> For instance, take your PetitSQL package.  If you do:
>  PPSqlGrammer new parse: 'select * form table'
> it will tell you that 'UPDATE' is expected at 0.  I'd much rather it
> determine what the best match was and tell you it failed there.  If
> you change the #command from that class to read:
>  command
>        ^ createCommand / deleteCommand / insertCommand / updateCommand / selectCommand
> and then run the above, it will instead tell you that 'FROM' expected
> at 9, which is what I would really like it to do.

The choice always reports the last error. Earlier version of
PetitParser used to report the error that consumed most input, but I
changed it because this was less predictable and less efficient than
the current implementation. You can create your own choice parser and
return the deepest failure if you think the old behavior is better.

> Is this possible out of the box?  If not, can you give me some
> guidance on how I could make it work this way?

What I typically do is to insert failures at particular choices in the
grammar, for example:

   PPSqlGrammer>>command
        ^ createCommand / deleteCommand / insertCommand / selectCommand /
updateCommand / (PPFailingParser message: 'Command expected')

Lukas

--
Lukas Renggli
www.lukas-renggli.ch

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