This is Rakudo version 2017.07-155-gc229022cb built on MoarVM version
2017.07-378-g5e94da03
implementing Perl 6.c.

Linux Kataomoi 4.13.0-rc6
CPU E3-1230 V2 @ 3.30GHz GenuineIntel GNU/Linux

Also tested on IRC with Moar and Star


On Tue, Aug 29, 2017 at 1:22 PM, perl6 via RT <perl6-bugs-follo...@perl.org>
wrote:

> Greetings,
>
> This message has been automatically generated in response to the
> creation of a trouble ticket regarding:
>         "[REGEX] Longest Alternation followed by an Alternation fails",
> a summary of which appears below.
>
> There is no need to reply to this message right now.  Your ticket has been
> assigned an ID of [perl #131991].
>
> Please include the string:
>
>          [perl #131991]
>
> in the subject line of all future correspondence about this issue. To do
> so,
> you may reply to this message.
>
>                         Thank you,
>                         perl6-bugs-follo...@perl.org
>
> -------------------------------------------------------------------------
> *Description:*
> Longest alternation seems to only evaluate the first nested alternation of
> its right side arguments.
> That is, if the first regex of an alternation <||> following longest
> alternation <|>  fails, and the regex preceding the longest alternation
> succeeds, the longest alternation uses the preceding/ left side match
> rather than evaluating the rest of the right side alternation which could
> have a potentially longer match.
>
> *Example 1:*
> 'succeed'.match(/ suc | [ fail || succeed ]/).say;
>
> Returns:
> 「suc」
>
> Expected:
> 「succeed」
>
> *Example 2:*
> grammar TEST {
>     regex NestedAlternation { fail || succeed }
>     regex LongestAlternation { suc | <NestedAlternation> }
>     regex TOP { <LongestAlternation> .* }
> }
> TEST.parse('succeed').say;
>
> Returns:
> 「succeed」
>  LongestAlternation => 「suc」
>
> Expected:
> 「succeed」
>  LongestAlternation => 「succeed」
>   NestedAlternation => 「succeed」
>
> Note if we remove the trailing '.*' in TOP, backtracking forces it to
> evaluate the NestedAlternation and return the expected result. However,
> backtracking back into the NestedAlternation should not be necessary.
>
> *Example 3:*
> grammar TEST {
>     token NestedAlternation { fail || succeed }
>     token LongestAlternation { suc | <NestedAlternation> }
>     token TOP { <LongestAlternation> }
> }
> TEST.parse('succeed').say;
>
>
> Returns:
> Nil
>
> Expected:
> 「succeed」
>  LongestAlternation => 「succeed」
>   NestedAlternation => 「succeed」
>
>

Reply via email to