develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34532 - in branches/rvar/languages/perl6/src: classes parser

From:
pmichaud
Date:
December 28, 2008 17:20
Subject:
[svn:parrot] r34532 - in branches/rvar/languages/perl6/src: classes parser
Message ID:
20081229012037.61A1CCB9FA@x12.develooper.com
Author: pmichaud
Date: Sun Dec 28 17:20:36 2008
New Revision: 34532

Modified:
   branches/rvar/languages/perl6/src/classes/Signature.pir
   branches/rvar/languages/perl6/src/parser/actions.pm
   branches/rvar/languages/perl6/src/parser/grammar.pg

Log:
[rakudo]:  Add is rw, is copy traits to parameters.


Modified: branches/rvar/languages/perl6/src/classes/Signature.pir
==============================================================================
--- branches/rvar/languages/perl6/src/classes/Signature.pir	(original)
+++ branches/rvar/languages/perl6/src/classes/Signature.pir	Sun Dec 28 17:20:36 2008
@@ -214,8 +214,7 @@
     ## handle readonly/copy traits
     $S0 = param['readtype']
     if $S0 == 'rw' goto param_readtype_done
-    $I0 = isntsame orig, var
-    if $I0 goto param_readtype_var
+    ne_addr orig, var, param_readtype_var
     var = new 'ObjectRef', var
   param_readtype_var:
     if $S0 == 'copy' goto param_readtype_done

Modified: branches/rvar/languages/perl6/src/parser/actions.pm
==============================================================================
--- branches/rvar/languages/perl6/src/parser/actions.pm	(original)
+++ branches/rvar/languages/perl6/src/parser/actions.pm	Sun Dec 28 17:20:36 2008
@@ -878,6 +878,27 @@
 }
 
 
+method trait($/) {
+    my $past;
+    if $<trait_auxiliary> {
+        $past := $( $<trait_auxiliary> );
+    }
+    elsif $<trait_verb> {
+        $past := $( $<trait_verb> );
+    }
+    make $past;
+}
+
+method trait_auxiliary($/) {
+    my $sym := ~$<sym>;
+    my $trait;
+    if $sym eq 'is' {
+        $trait := ~$<name>;
+    }
+    make PAST::Op.new( :name('list'), 'trait_auxiliary:' ~ $sym, $trait );
+}
+    
+
 method signature($/, $key) {
     our $?SIGNATURE;
     our $?SIGNATURE_BLOCK;
@@ -999,16 +1020,16 @@
     }
 
     my $readtype := '';
-    #for @($<trait>) {
-    #    my $traitpast := $( $_ );
-    #    my $name := $traitpast[1];
-    #    if $name eq 'readonly' || $name eq 'rw' || $name eq 'copy' {
-    #        $readtype && 
-    #            $/.panic("Can only use one of readonly, rw, and copy");
-    #        $readtype := $name;
-    #    }
-    #    # else $traitlist.push( $traitpast );  ## when we do other traits
-    #}
+    for @($<trait>) {
+        my $traitpast := $( $_ );
+        my $name := $traitpast[1];
+        if $name eq 'readonly' || $name eq 'rw' || $name eq 'copy' {
+            $readtype && 
+                $/.panic("Can only use one of readonly, rw, and copy");
+            $readtype := $name;
+        }
+        # else $traitlist.push( $traitpast );  ## when we do other traits
+    }
     $symbol<readtype> := PAST::Val.new( :value($readtype || 'readonly') );
 
     make $past;

Modified: branches/rvar/languages/perl6/src/parser/grammar.pg
==============================================================================
--- branches/rvar/languages/perl6/src/parser/grammar.pg	(original)
+++ branches/rvar/languages/perl6/src/parser/grammar.pg	Sun Dec 28 17:20:36 2008
@@ -387,14 +387,20 @@
 }
 
 rule trait {
+    [
     | <trait_auxiliary>
     | <trait_verb>
+    ]
+    {*}
 }
 
 rule trait_auxiliary {
+    [
     | $<sym>=[is] <name><postcircumfix>?
     | $<sym>=[does] <name>['['<EXPR>']']?
     | $<sym>=[will] <identifier> <block>
+    ]
+    {*}
 }
 
 rule trait_verb {



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About