From 3c2e872eb5d0cdf4d7c5556a3c2a5c5be4940b7a Mon Sep 17 00:00:00 2001 From: jnthn Date: Mon, 29 Jun 2009 11:23:29 +0200 Subject: [PATCH] Parse traits before handling the block open, so we can look for some that affect the compile. Also, attatch them to the package so PAST node so we can look for those we care about later. --- src/parser/actions.pm | 4 ++++ src/parser/grammar.pg | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/parser/actions.pm b/src/parser/actions.pm index a36f7d419d4..07d85b63356 100644 --- a/src/parser/actions.pm +++ b/src/parser/actions.pm @@ -1423,10 +1423,14 @@ method package_declarator($/, $key) { my $sym := ~$; my $past; if $key eq 'open' { + # Start of a package. Create a block and mark it as a package declaration. our $?BLOCK_OPEN; $?BLOCK_OPEN := PAST::Block.new( PAST::Stmts.new(), :node($/) ); $?BLOCK_OPEN := $sym; @?PKGDECL.unshift( $sym ); + + # Attach traits list to it. + $?BLOCK_OPEN := $; } elsif $key eq 'package_def' { make $.ast; diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg index 51098c450ef..07721dbf9c5 100644 --- a/src/parser/grammar.pg +++ b/src/parser/grammar.pg @@ -702,8 +702,8 @@ rule package_def { match.'add_type'($S0) }} ]? - {*} #= open * + {*} #= open [ | {*} #= block |