PetitParser problem with plus

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

PetitParser problem with plus

jgfoster
There is something about plus that I don’t understand. In the following code if I parse for (x , x) then I get what I expect. If I parse for (x plus) then the image hangs. What am I doing wrong?

James

| a notA x y |
a := $a asParser.
notA := $a asParser negate star flatten.
x := a / notA.
y := x , x. “works fine”
y := x plus. “never finishes”
^y end parse: 'ab’.


Reply | Threaded
Open this post in threaded view
|

Re: PetitParser problem with plus

Guillaume Larcheveque
With x, x it will only go to 2 level deep.

With the plus you allow to go as far as the x rule succeed and your x rule always succeed because notA always succeed due to the star without consuming anything so you fall into infinite loop.

2014-12-18 6:47 GMT+01:00 James Foster <[hidden email]>:
There is something about plus that I don’t understand. In the following code if I parse for (x , x) then I get what I expect. If I parse for (x plus) then the image hangs. What am I doing wrong?

James

| a notA x y |
a := $a asParser.
notA := $a asParser negate star flatten.
x := a / notA.
y := x , x.     “works fine”
y := x plus. “never finishes”
^y end parse: 'ab’.




--
Guillaume Larcheveque

Reply | Threaded
Open this post in threaded view
|

Re: PetitParser problem with plus

Guillaume Larcheveque
So you just have to remove the #star in notA or replace it by #plus to makes it succeed only when it consume at least one character

2014-12-18 7:54 GMT+01:00 Guillaume Larcheveque <[hidden email]>:
With x, x it will only go to 2 level deep.

With the plus you allow to go as far as the x rule succeed and your x rule always succeed because notA always succeed due to the star without consuming anything so you fall into infinite loop.

2014-12-18 6:47 GMT+01:00 James Foster <[hidden email]>:
There is something about plus that I don’t understand. In the following code if I parse for (x , x) then I get what I expect. If I parse for (x plus) then the image hangs. What am I doing wrong?

James

| a notA x y |
a := $a asParser.
notA := $a asParser negate star flatten.
x := a / notA.
y := x , x.     “works fine”
y := x plus. “never finishes”
^y end parse: 'ab’.




--
Guillaume Larcheveque



--
Guillaume Larcheveque

Reply | Threaded
Open this post in threaded view
|

Re: PetitParser problem with plus

kurs.jan
Exactly...

This happens so often that we should add some warning somewhere in these cases....


Cheers,
Jan

On 18 December 2014 at 08:36, Guillaume Larcheveque <[hidden email]> wrote:
So you just have to remove the #star in notA or replace it by #plus to makes it succeed only when it consume at least one character

2014-12-18 7:54 GMT+01:00 Guillaume Larcheveque <[hidden email]>:
With x, x it will only go to 2 level deep.

With the plus you allow to go as far as the x rule succeed and your x rule always succeed because notA always succeed due to the star without consuming anything so you fall into infinite loop.

2014-12-18 6:47 GMT+01:00 James Foster <[hidden email]>:
There is something about plus that I don’t understand. In the following code if I parse for (x , x) then I get what I expect. If I parse for (x plus) then the image hangs. What am I doing wrong?

James

| a notA x y |
a := $a asParser.
notA := $a asParser negate star flatten.
x := a / notA.
y := x , x.     “works fine”
y := x plus. “never finishes”
^y end parse: 'ab’.




--
Guillaume Larcheveque



--
Guillaume Larcheveque

Reply | Threaded
Open this post in threaded view
|

Re: PetitParser problem with plus

jgfoster
In reply to this post by Guillaume Larcheveque
That did it and it makes sense. Thanks so much!

On Dec 17, 2014, at 11:36 PM, Guillaume Larcheveque <[hidden email]> wrote:

So you just have to remove the #star in notA or replace it by #plus to makes it succeed only when it consume at least one character

2014-12-18 7:54 GMT+01:00 Guillaume Larcheveque <[hidden email]>:
With x, x it will only go to 2 level deep.

With the plus you allow to go as far as the x rule succeed and your x rule always succeed because notA always succeed due to the star without consuming anything so you fall into infinite loop.

2014-12-18 6:47 GMT+01:00 James Foster <[hidden email]>:
There is something about plus that I don’t understand. In the following code if I parse for (x , x) then I get what I expect. If I parse for (x plus) then the image hangs. What am I doing wrong?

James

| a notA x y |
a := $a asParser.
notA := $a asParser negate star flatten.
x := a / notA.
y := x , x.     “works fine”
y := x plus. “never finishes”
^y end parse: 'ab’.




--
Guillaume Larcheveque



--
Guillaume Larcheveque


Reply | Threaded
Open this post in threaded view
|

Re: PetitParser problem with plus

stepharo
In reply to this post by kurs.jan
Could one of you write a small paragraph for the petit parser chapter?

Le 18/12/14 09:07, Jan Kurš a écrit :
Exactly...

This happens so often that we should add some warning somewhere in these cases....


Cheers,
Jan

On 18 December 2014 at 08:36, Guillaume Larcheveque <[hidden email]> wrote:
So you just have to remove the #star in notA or replace it by #plus to makes it succeed only when it consume at least one character

2014-12-18 7:54 GMT+01:00 Guillaume Larcheveque <[hidden email]>:
With x, x it will only go to 2 level deep.

With the plus you allow to go as far as the x rule succeed and your x rule always succeed because notA always succeed due to the star without consuming anything so you fall into infinite loop.

2014-12-18 6:47 GMT+01:00 James Foster <[hidden email]>:
There is something about plus that I don’t understand. In the following code if I parse for (x , x) then I get what I expect. If I parse for (x plus) then the image hangs. What am I doing wrong?

James

| a notA x y |
a := $a asParser.
notA := $a asParser negate star flatten.
x := a / notA.
y := x , x.     “works fine”
y := x plus. “never finishes”
^y end parse: 'ab’.




--
Guillaume Larcheveque



--
Guillaume Larcheveque


Reply | Threaded
Open this post in threaded view
|

Re: PetitParser problem with plus

kurs.jan
You mean deep into pharo? Or something else? I can do this...

On 21 December 2014 at 13:27, stepharo <[hidden email]> wrote:
Could one of you write a small paragraph for the petit parser chapter?

Le 18/12/14 09:07, Jan Kurš a écrit :
Exactly...

This happens so often that we should add some warning somewhere in these cases....


Cheers,
Jan

On 18 December 2014 at 08:36, Guillaume Larcheveque <[hidden email]> wrote:
So you just have to remove the #star in notA or replace it by #plus to makes it succeed only when it consume at least one character

2014-12-18 7:54 GMT+01:00 Guillaume Larcheveque <[hidden email]>:
With x, x it will only go to 2 level deep.

With the plus you allow to go as far as the x rule succeed and your x rule always succeed because notA always succeed due to the star without consuming anything so you fall into infinite loop.

2014-12-18 6:47 GMT+01:00 James Foster <[hidden email]>:
There is something about plus that I don’t understand. In the following code if I parse for (x , x) then I get what I expect. If I parse for (x plus) then the image hangs. What am I doing wrong?

James

| a notA x y |
a := $a asParser.
notA := $a asParser negate star flatten.
x := a / notA.
y := x , x.     “works fine”
y := x plus. “never finishes”
^y end parse: 'ab’.




--
Guillaume Larcheveque



--
Guillaume Larcheveque



Reply | Threaded
Open this post in threaded view
|

Re: PetitParser problem with plus

stepharo

Le 31/12/14 16:37, Jan Kurš a écrit :
You mean deep into pharo? Or something else? I can do this...

Yes I mean let us improve **OUR** documentation.
Soon we will release an official version of Deep into Pharo. Then we will convert it to pillar and this means that we will
all the Pharo books online and on different formats.

Stef

On 21 December 2014 at 13:27, stepharo <[hidden email]> wrote:
Could one of you write a small paragraph for the petit parser chapter?

Le 18/12/14 09:07, Jan Kurš a écrit :
Exactly...

This happens so often that we should add some warning somewhere in these cases....


Cheers,
Jan

On 18 December 2014 at 08:36, Guillaume Larcheveque <[hidden email]> wrote:
So you just have to remove the #star in notA or replace it by #plus to makes it succeed only when it consume at least one character

2014-12-18 7:54 GMT+01:00 Guillaume Larcheveque <[hidden email]>:
With x, x it will only go to 2 level deep.

With the plus you allow to go as far as the x rule succeed and your x rule always succeed because notA always succeed due to the star without consuming anything so you fall into infinite loop.

2014-12-18 6:47 GMT+01:00 James Foster <[hidden email]>:
There is something about plus that I don’t understand. In the following code if I parse for (x , x) then I get what I expect. If I parse for (x plus) then the image hangs. What am I doing wrong?

James

| a notA x y |
a := $a asParser.
notA := $a asParser negate star flatten.
x := a / notA.
y := x , x.     “works fine”
y := x plus. “never finishes”
^y end parse: 'ab’.




--
Guillaume Larcheveque



--
Guillaume Larcheveque