Skip Menu |
Report information
Id: 130612
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: ronaldxs <ronaldxs [at] software-path.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: Ronald Schmidt <ronaldxs [...] software-path.com>
Date: Sat, 21 Jan 2017 19:32:15 +0100
To: rakudobug [...] perl.org
Subject: [BUG] LTM doesn't use text order for tie break as expected

# https://design.perl6.org/S05.html#Longest-token_matching says:
Show quoted text

# For matches of same length ... If the alternatives are in the same
# grammar file, the textually earlier alternative takes precedence.

use Test;

grammar text-order {
    token alt-na_1 { <n> | <na_1> };
    token alt-na_2 { <n> | <na_2> };
    token n { <digit>+ }
    token na_1 { <+alpha +digit> + }
    token na_2 { <+alpha +[0..9]> + }
}

is text-order.parse('1', :rule<alt-na_1>).keys[0], 'n',
    'Match first textual rule OK';
is text-order.parse('1', :rule<alt-na_2>).keys[0], 'n',
'Match second textual rule fail';

result:

ok 1 - Match first textual rule OK
not ok 2 - Match second textual rule fail
# Failed test 'Match second textual rule fail'
# at <tmp> line 17
# expected: 'n
#      got: 'na_2'

Posted on IRC, https://irclog.perlgeek.de/perl6/2017-01-20#i_13960886

The IRC discussion notes that the tests should be expected to pass and the S05 rule is intended for implementation in current Perl 6 / Rakudo.

See also roast issue: https://github.com/perl6/roast/issues/224

 


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org