Skip Menu |
Report information
Id: 60358
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

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



Subject: Rakudo doesn't recognize grammars with :: in the name
Date: Wed, 5 Nov 2008 22:43:38 +0100
To: rakudobug [...] perl.org
From: "Carl Mäsak" <cmasak [...] gmail.com>
Download (untitled) / with headers
text/plain 218b
<masak> rakudo: grammar A { token foo { foo } }; say "foo" ~~ A::foo <p6eval> rakudo 32364: OUTPUT[foo␤] <masak> rakudo: grammar A::B { token foo { foo } }; say "foo" ~~ A::B::foo <p6eval> rakudo 32364: OUTPUT[0␤]
Download (untitled) / with headers
text/plain 849b
On Wed Nov 05 13:43:54 2008, masak wrote: Show quoted text
> <masak> rakudo: grammar A { token foo { foo } }; say "foo" ~~ A::foo > <p6eval> rakudo 32364: OUTPUT[foo␤] > <masak> rakudo: grammar A::B { token foo { foo } }; say "foo" ~~ A::B::foo > <p6eval> rakudo 32364: OUTPUT[0␤]
The problem is more evident in PIR. The grammar reduces to something like this: .namespace ["PDF::Grammar"] .sub "literal_string" :method instead of this: .namespace ["PDF";"Grammar"] .sub "literal_string" :method I think the fault is in languages/perl6/src/parser/actions.pm method regex_declarator_rule($/) { ... $past.name( ~$<identifier>[0] ); (as well as regex_declarator_regex and regex_declarator_token). If these took <name> instead of <identifier>, just like <package_def> does, then maybe that would help, but I'm not sure.
It took a while to understand the code, but the solution was a one-liner. Patch attached.
Download RT#60358.patch
text/plain 479b
Index: src/parser/actions.pm =================================================================== --- src/parser/actions.pm (revision 32369) +++ src/parser/actions.pm (working copy) @@ -2544,7 +2544,7 @@ $past := PAST::Block.new( $<quote_regex>, :compiler('PGE::Perl6Regex'), - :namespace($?NS), + :namespace(Perl6::Compiler.parse_name( $?NS )), :blocktype('declaration'), :node( $/ ) );
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 445b
On Wed Nov 05 19:31:36 2008, chrisdolan wrote: Show quoted text
> It took a while to understand the code, but the solution was a > one-liner. Patch attached.
Unfortunately, the patch produced a bunch of spectest failures. However, it wasn't because the patch was wrong, but rather a bug in some code generation in PCT. I fixed that, and then the patch worked and did the Right Thing, so it's applied in r32546. Plus got us spectesting this. Thanks! Jonathan


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