Hi,
I played a bit, and it is definitely possible. Here is an example:
delimiter := $. asParser.
ignoreStatement := delimiter negate star.
statement := #word asParser plus >=> [:stream : continuation |
| result |
result := continuation value.
result isPetitFailure
ifTrue: [ ignoreStatement parseOn: stream ]
ifFalse: [ result ] ].
statements := ( statement, delimiter ) star.
statements end parse: 'aaa.,,.aa.'
I have the original parser that parses simple statements based on #word. And then, from
outside, I wrap the statement parser to handle a failure case with an ignoreStatement
parser that ignores everything up to the first dot.
We could use this way of wrapping in a subclass of PPSmalltalkParser.
Cheers,
Doru
On May 31, 2013, at 11:15 AM, Tudor Girba <tudor(a)tudorgirba.com> wrote:
What do you mean by error handling? A way to make the
parser work not break on only partially correct code? That would be indeed great.
Perhaps we can deal with it by wrapping the parser objects with error handling. There
already exists support for wrapping parsers. Take a look at:
PPParser>>>=>
Cheers,
Doru
On Fri, May 31, 2013 at 11:03 AM, Stéphane Ducasse <stephane.ducasse(a)inria.fr>
wrote:
We would like to see if we can use PetitParser to build syntax hilighting and for this
we need to see if there is a way to specify error handling.
Does any of you know?
So far we tried to use the RBSCanner but it does not really work for what we need
Stef
_______________________________________________
Moose-dev mailing list
Moose-dev(a)iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
--
www.tudorgirba.com
"Every thing has its own flow"
--
www.tudorgirba.com
"Innovation comes in the least expected form.
That is, if it is expected, it already happened."