Created
July 31, 2011 07:30
-
-
Save tadzik/1116532 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm | |
index d88ef97..0fc8d04 100644 | |
--- a/src/Perl6/Actions.pm | |
+++ b/src/Perl6/Actions.pm | |
@@ -33,6 +33,8 @@ class Perl6::Actions is HLL::Actions { | |
our $FORBID_PIR; | |
our $STATEMENT_PRINT; | |
+ our $?DOC; | |
+ | |
INIT { | |
# initialize @PACKAGE | |
our @PACKAGE := Q:PIR { %r = root_new ['parrot';'ResizablePMCArray'] }; | |
@@ -118,10 +120,10 @@ class Perl6::Actions is HLL::Actions { | |
method comp_unit($/, $key?) { | |
our $?RAKUDO_HLL; | |
- | |
+ | |
# Checks. | |
$*ST.assert_stubs_defined(); | |
- | |
+ | |
# Get the block for the unit mainline code. | |
my $unit := $*UNIT; | |
my $mainline := PAST::Stmts.new( | |
@@ -135,7 +137,11 @@ class Perl6::Actions is HLL::Actions { | |
elsif %*COMPILING<%?OPTIONS><n> { | |
$mainline := wrap_option_n_code($mainline); | |
} | |
- | |
+ | |
+ # FIXME: It's too late to set this one already. | |
+ # Where does it belong? | |
+ $?DOC := %*COMPILING<%?OPTIONS><doc>; | |
+ | |
# Unit needs to have a load-init holding the deserialization or | |
# fixup code for this compilation unit. | |
$unit.loadinit().push($*ST.to_past()); | |
@@ -711,6 +717,12 @@ class Perl6::Actions is HLL::Actions { | |
method statement_prefix:sym<INIT>($/) { $*ST.add_phaser($/, ($<blorst>.ast)<code_object>, 'INIT'); } | |
method statement_prefix:sym<END>($/) { $*ST.add_phaser($/, ($<blorst>.ast)<code_object>, 'END'); } | |
+ method statement_prefix:sym<DOC>($/) { | |
+ if $?DOC { | |
+ $*ST.add_phaser($/, ($<blorst>.ast)<code_object>, ~$<phase>); | |
+ } | |
+ } | |
+ | |
method statement_prefix:sym<do>($/) { | |
make PAST::Op.new( :pasttype('call'), $<blorst>.ast ); | |
} | |
diff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm | |
index 454bbea..4397f42 100644 | |
--- a/src/Perl6/Grammar.pm | |
+++ b/src/Perl6/Grammar.pm | |
@@ -681,6 +681,10 @@ grammar Perl6::Grammar is HLL::Grammar { | |
token statement_prefix:sym<try> { <sym> <blorst> } | |
token statement_prefix:sym<gather>{ <sym> <blorst> } | |
token statement_prefix:sym<do> { <sym> <blorst> } | |
+ token statement_prefix:sym<DOC> { | |
+ <sym> \s <.ws> $<phase>=['BEGIN' || 'CHECK' || 'INIT'] | |
+ <blorst> | |
+ } | |
token blorst { | |
\s <.ws> [ <?[{]> <block> | <statement> ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment