Author: jonathan
Date: Tue Mar 25 15:17:48 2008
New Revision: 26546

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

Log:
[rakudo] Treat pairs in parameter lists as named arguments.

Modified: trunk/languages/perl6/src/parser/actions.pm
==============================================================================
--- trunk/languages/perl6/src/parser/actions.pm (original)
+++ trunk/languages/perl6/src/parser/actions.pm Tue Mar 25 15:17:48 2008
@@ -472,7 +472,9 @@
         $past := PAST::Op.new();
     }
     else {
-        $past := $( $/{$key} );
+        $past := PAST::Op.new();
+        my $args := $( $/{$key} );
+        process_arguments($past, $args);
     }
     $past.pasttype('callmethod');
     $past.node($/);
@@ -504,9 +506,7 @@
     elsif $key eq '( )' {
         my $semilist := $( $<semilist> );
         $past := PAST::Op.new( :node($/), :pasttype('call') );
-        for @($semilist) {
-            $past.push( $_ );
-        }
+        process_arguments($past, $semilist);
     }
     elsif $key eq '{ }' {
         my $semilist := $( $<semilist> );
@@ -1117,10 +1117,17 @@
 
 
 method subcall($/) {
-    my $past := $($<semilist>);
-    $past.name( ~$<ident> );
-    $past.pasttype('call');
-    $past.node($/);
+    # Build call node.
+    my $past := PAST::Op.new(
+        :name( ~$<ident> ),
+        :pasttype('call'),
+        :node($/)
+    );
+
+    # Process arguments.
+    my $args := $( $<semilist> );
+    process_arguments($past, $args);
+
     make $past;
 }
 
@@ -1300,6 +1307,19 @@
 }
 
 
+# Used by all calling code to process arguments into the correct form.
+sub process_arguments($call_past, $args) {
+    for @($args) {
+        if $_.returns() eq 'Pair' {
+            $_[2].named($_[1]);
+            $call_past.push($_[2]);
+        } else {
+            $call_past.push($_);
+        }
+    }
+}
+
+
 # Local Variables:
 #   mode: cperl
 #   cperl-indent-level: 4

Reply via email to