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


Code:
say grammar Gram { regex TOP { ('XX')+ %% $<delim>=<[a..z]>* };
}.parse('XXXXXX');

Output:
「XXXXXX」
 0 => 「XX」
 0 => 「XX」
 delim => 「」
 0 => 「XX」
 delim => 「」
 delim => 「」

The order is wrong. I expected this:
「XXXXXX」
 0 => 「XX」
 delim => 「」
 0 => 「XX」
 delim => 「」
 0 => 「XX」
 delim => 「」

This problem is more obvious if you add actual delimiters (in which case it
works correctly):
say grammar Gram { regex TOP { ('XX')+ %% $<delim>=<[a..z]>* };
}.parse('XXaXXbXXc');

Output:
「XXaXXbXXc」
 0 => 「XX」
 delim => 「a」
 0 => 「XX」
 delim => 「b」
 0 => 「XX」
 delim => 「c」

This output is correct.

Reply via email to