lookup in petitparser ?

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

lookup in petitparser ?

Nicolas Anquetil
Is there a way nice way to do a lookup in PP ?

for example, I want to ensure that I have a 'a' then a 'b'.
But I don't wan't to consume 'b'

              'a' asParser , 'b' asParser lookup

currently I implemented it with a double not :-)

              'a' asParser , 'b' asParser not not

not very nice

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

Re: lookup in petitparser ?

cbc
I'm pretty sure this works:

$a asParser , $b and

       and "Answer a new parser (logical and-predicate) that succeeds
whenever the receiver does, but never consumes input."

(strings work, too, but if you just have 1 character...)

-Chris
On Wed, Oct 31, 2012 at 5:51 AM, Nicolas Anquetil
<[hidden email]> wrote:

> Is there a way nice way to do a lookup in PP ?
>
> for example, I want to ensure that I have a 'a' then a 'b'.
> But I don't wan't to consume 'b'
>
>              'a' asParser , 'b' asParser lookup
>
> currently I implemented it with a double not :-)
>
>              'a' asParser , 'b' asParser not not
>
> not very nice
>
> nicolas
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: lookup in petitparser ?

Tudor Girba-2
Exactly.

Look at:  PPParserTest>>testAnd

Cheers,
Doru


On 31 Oct 2012, at 23:57, Chris Cunningham <[hidden email]> wrote:

> I'm pretty sure this works:
>
> $a asParser , $b and
>
>       and "Answer a new parser (logical and-predicate) that succeeds
> whenever the receiver does, but never consumes input."
>
> (strings work, too, but if you just have 1 character...)
>
> -Chris
> On Wed, Oct 31, 2012 at 5:51 AM, Nicolas Anquetil
> <[hidden email]> wrote:
>> Is there a way nice way to do a lookup in PP ?
>>
>> for example, I want to ensure that I have a 'a' then a 'b'.
>> But I don't wan't to consume 'b'
>>
>>             'a' asParser , 'b' asParser lookup
>>
>> currently I implemented it with a double not :-)
>>
>>             'a' asParser , 'b' asParser not not
>>
>> not very nice
>>
>> nicolas
>> _______________________________________________
>> 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

--
www.tudorgirba.com

"We can create beautiful models in a vacuum.
But, to get them effective we have to deal with the inconvenience of reality."


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

Re: lookup in petitparser ?

Nicolas Anquetil
In reply to this post by cbc
great
thank you

nicolas

On 31/10/12 23:57, Chris Cunningham wrote:

> I'm pretty sure this works:
>
> $a asParser , $b and
>
>         and "Answer a new parser (logical and-predicate) that succeeds
> whenever the receiver does, but never consumes input."
>
> (strings work, too, but if you just have 1 character...)
>
> -Chris
> On Wed, Oct 31, 2012 at 5:51 AM, Nicolas Anquetil
> <[hidden email]> wrote:
>> Is there a way nice way to do a lookup in PP ?
>>
>> for example, I want to ensure that I have a 'a' then a 'b'.
>> But I don't wan't to consume 'b'
>>
>>               'a' asParser , 'b' asParser lookup
>>
>> currently I implemented it with a double not :-)
>>
>>               'a' asParser , 'b' asParser not not
>>
>> not very nice
>>
>> nicolas
>> _______________________________________________
>> 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

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