Author: jonathan
Date: Sat Jul 26 05:08:18 2008
New Revision: 29752

Modified:
   trunk/languages/perl6/src/parser/actions.pm
   trunk/languages/perl6/src/parser/grammar.pg

Log:
[rakudo] Make multi f() {} parse and work the same as multi sub f() {}. 
Resolves RT#57122.

Modified: trunk/languages/perl6/src/parser/actions.pm
==============================================================================
--- trunk/languages/perl6/src/parser/actions.pm (original)
+++ trunk/languages/perl6/src/parser/actions.pm Sat Jul 26 05:08:18 2008
@@ -412,8 +412,15 @@
 }
 
 
-method multi_declarator($/) {
-    my $past := $( $<routine_declarator> );
+method multi_declarator($/, $key) {
+    my $past := $( $/{$key} );
+
+    # If we just got a routine_def, make it a sub.
+    if $key eq 'routine_def' {
+        create_sub($/, $past);
+    }
+
+    # If it was multi, then emit a :multi and a type list.
     if $<sym> eq 'multi' {
         our $?PARAM_TYPE_CHECK;
         my @check_list := @($?PARAM_TYPE_CHECK);
@@ -475,11 +482,7 @@
     my $past;
     if $key eq 'sub' {
         $past := $($<routine_def>);
-        $past.blocktype('declaration');
-        set_block_proto($past, 'Sub');
-        if $<routine_def><multisig> {
-            set_block_sig($past, $( $<routine_def><multisig>[0]<signature> ));
-        }
+        create_sub($/, $past);
     }
     elsif $key eq 'method' {
         $past := $($<method_def>);
@@ -2909,6 +2912,16 @@
 }
 
 
+# Takes a block and turns it into a sub.
+sub create_sub($/, $past) {
+    $past.blocktype('declaration');
+    set_block_proto($past, 'Sub');
+    if $<routine_def><multisig> {
+        set_block_sig($past, $( $<routine_def><multisig>[0]<signature> ));
+    }
+}
+
+
 # Get's the :immediate setup sub for a block; if it doesn't have one, adds it.
 sub get_block_setup_sub($block) {
     my $init := $block[0];

Modified: trunk/languages/perl6/src/parser/grammar.pg
==============================================================================
--- trunk/languages/perl6/src/parser/grammar.pg (original)
+++ trunk/languages/perl6/src/parser/grammar.pg Sat Jul 26 05:08:18 2008
@@ -324,7 +324,10 @@
 #### Subroutine and method definitions ####
 
 rule multi_declarator {
-    $<sym>=[multi|proto|only] <routine_declarator> {*}
+    $<sym>=[multi|proto|only] 
+    [ <routine_declarator> {*}                   #= routine_declarator
+    | <routine_def> {*}                          #= routine_def
+    ]
 }
 
 token routine_declarator {

Reply via email to