Petit parser and negation

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

Petit parser and negation

NorbertHartl
I'm trying to parse a negated character with petit parser. I'm trying to parse

[^"]*

but the only thing I came up with is

($" asParser not, #any asParser) star flatten

Is there a better way to parse it or is this just the way to go? The not consuming not parser is indeed useful if I need a combination of negation but the straight forward thing I try to solve looks cumbersome.

thanks,

Norbert


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

Re: Petit parser and negation

Tudor Girba
Hi,

This is almost the way to go :). There already is a predefined operator that does the consuming: negate.

So you would have:
$" asParser negate star flatten

Cheers,
Doru



On 27 Apr 2011, at 09:09, Norbert Hartl wrote:

> I'm trying to parse a negated character with petit parser. I'm trying to parse
>
> [^"]*
>
> but the only thing I came up with is
>
> ($" asParser not, #any asParser) star flatten
>
> Is there a better way to parse it or is this just the way to go? The not consuming not parser is indeed useful if I need a combination of negation but the straight forward thing I try to solve looks cumbersome.
>
> thanks,
>
> Norbert
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev

--
www.tudorgirba.com

"Not knowing how to do something is not an argument for how it cannot be done."


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

Re: Petit parser and negation

NorbertHartl

Am 27.04.2011 um 09:28 schrieb Tudor Girba:

> Hi,
>
> This is almost the way to go :). There already is a predefined operator that does the consuming: negate.
>
> So you would have:
> $" asParser negate star flatten
>
Thanks, that's what I was searching for. Works great.

Norbert

>
>
> On 27 Apr 2011, at 09:09, Norbert Hartl wrote:
>
>> I'm trying to parse a negated character with petit parser. I'm trying to parse
>>
>> [^"]*
>>
>> but the only thing I came up with is
>>
>> ($" asParser not, #any asParser) star flatten
>>
>> Is there a better way to parse it or is this just the way to go? The not consuming not parser is indeed useful if I need a combination of negation but the straight forward thing I try to solve looks cumbersome.
>>
>> thanks,
>>
>> Norbert
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
> --
> www.tudorgirba.com
>
> "Not knowing how to do something is not an argument for how it cannot be done."
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev


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