develooper Front page | perl.cvs.parrot | Postings from January 2009

[svn:parrot] r34962 - branches/rvar/languages/perl6/src/parser

From:
pmichaud
Date:
January 4, 2009 22:32
Subject:
[svn:parrot] r34962 - branches/rvar/languages/perl6/src/parser
Message ID:
20090105063155.0EC06CB9F9@x12.develooper.com
Author: pmichaud
Date: Sun Jan  4 22:31:54 2009
New Revision: 34962

Modified:
   branches/rvar/languages/perl6/src/parser/actions.pm

Log:
[rakudo]:  Throw exception on attempts to define attributes outside of classes


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 Jan  4 22:31:54 2009
@@ -1324,6 +1324,9 @@
     my $sym := ~$<sym>;
     my $past;
     if $key eq 'open' {
+        our $?BLOCK_OPEN;
+        $?BLOCK_OPEN := PAST::Block.new( PAST::Stmts.new(), :node($/) );
+        $?BLOCK_OPEN<pkgdecl> := $sym;
         @?PKGDECL.unshift( $sym );
     }
     else {
@@ -1460,6 +1463,12 @@
             }
             
             if $scope eq 'attribute' {
+                my $pkgdecl := $block<pkgdecl>;
+                unless $pkgdecl eq 'class' || $pkgdecl eq 'role' 
+                        || $pkgdecl eq 'grammar' {
+                    $/.panic("Attempt to define attribute " ~ $var.name() ~
+                             " outside of class, role, or grammar");
+                }
                 # Attribute declaration.  Add code to the beginning
                 # of the block (really class/grammar/role) to
                 # create the attribute.



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