# New Ticket Created by  Stephane Payrard 
# Please include the string:  [perl #111288]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=111288 >


$ perl6
> (grammar { token TOP {  <a>? $<b>='b' }; token a  {  a  } }).parse: 'ab'; say 
> $/<b>.keys;
a
> (grammar { token TOP {  <a> $<b>='b' }; token a  {  a  } }).parse: 'ab'; say 
> $/<b>.keys;
>

In the first line $/<b>.keys is not empty contrary to expectations.
Somehow the results of the <a>?
rule leaks into $/<b>.
Note that in the second line, the question mark in <a>?  is suppressed
and the bug is not triggered any more.

Maybe the bug will be fixed  when the implementation of ? will be
rewritten as per spec (not returning an array).



<cognominal>    nom: (grammar { token TOP {  <a>? $<b>='b' }; token a  {
a  } }).parse: 'ab'; say $/<b>.keys;
<p6eval>        nom 4130f6: OUTPUT«a␤»
<cognominal>    nom: (grammar { token TOP {  <a> $<b>='b' }; token a  {
a  } }).parse: 'ab'; say $/<b>.keys;
<p6eval>        nom 4130f6: OUTPUT«␤»
<cognominal>    jnthn, this does not make any sense to me that $/<b>.keys
 returns anything different than a void Parcel
<cognominal>    should I file a bug?
*       NamelessTee has quit (Ping timeout: 244 seconds)
<moritz>        nom: (grammar { token TOP {  <a> $<b>='b' }; token {  a  }
}).parse: 'ab'; say $/<b>.keys.WHAT;
<p6eval>        nom 4130f6: OUTPUT«Method 'a' not found for invocant of class
'<anon>'␤  in regex TOP at /tmp/fZXy8AXoHU:1␤  in method parse at
src/gen/CORE.setting:8019␤  in block <anon> at /tmp/fZXy8AXoHU:1␤␤»
<moritz>        nom: (grammar { token TOP {  <a> $<b>='b' }; token a {  a  }
}).parse: 'ab'; say $/<b>.keys.WHAT;
<p6eval>        nom 4130f6: OUTPUT«List()␤»
<moritz>        cognominal: it's returns an empty List, not an empty Parcel.
Is that your problem?
<cognominal>    see the first example, it prints "a\n".
<cognominal>    I don't care if it is a parcel or a list. Whatever it is
should be empty.
<moritz>        agreed
<cognominal>    it does not happen when I delete the '?' suffix.
<moritz>        though of course the ? quantifier on <a> should not affect $<b>
<cognominal>    yes, that's my point.
<moritz>        agreed. Bug it is.






-- 
cognominal stef

Reply via email to