Author: bernhard
Date: Wed Dec 24 04:56:59 2008
New Revision: 34333
Modified:
trunk/languages/pipp/src/pct/actions.pm
trunk/languages/pipp/src/pct/grammar.pg
trunk/languages/pipp/src/pipp.pir
Log:
[Pipp] Remove unneeded explicit loading of PGE-libs.
Initialize @?BLOCK as ResizablePMCArray.
Start with keeping track of blocks and associated symbol tables.
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Wed Dec 24 04:56:59 2008
@@ -20,8 +20,8 @@
class Pipp::Grammar::Actions;
method TOP($/, $key) {
- our $?BLOCK;
- our @?BLOCK; # keep track of the current block
+ our @?BLOCK; # A stack of PAST::Block
+ our $?BLOCK; # The current block. Used for managing the symbol table.
if $key eq 'open' {
$?BLOCK := PAST::Block.new(
@@ -41,14 +41,19 @@
$?BLOCK.symbol( :scope('package'), '$_SESSION' );
$?BLOCK.symbol( :scope('package'), '$_REQUEST' );
$?BLOCK.symbol( :scope('package'), '$_ENV' );
+ @?BLOCK.unshift($?BLOCK);
}
- elsif $key eq 'close' {
+ else {
+ # retrieve the block created in the "if" section in this method.
+ #my $past := @?BLOCK.shift(); # for some reason @?BLOCK can be empty
+ my $past := $?BLOCK;
+
# a PHP script consists of a list of statements
for $<sea_or_code> {
- $?BLOCK.push( $($_) );
+ $past.push( $($_) );
}
- make $?BLOCK;
+ make $past;
}
}
@@ -481,6 +486,7 @@
# note that $<param_list> creates a new PAST::Block.
my $past := $( $<param_list> );
+ # TODO: set $?BLOCK
$past.name( ~$<FUNCTION_NAME> );
$past.control('return_pir');
@@ -505,6 +511,7 @@
# note that $<param_list> creates a new PAST::Block.
my $past := $( $<param_list> );
+ # TODO: set $?BLOCK
$past.name( ~$<METHOD_NAME> );
$past.blocktype( 'method' );
@@ -520,6 +527,7 @@
:blocktype('declaration'),
:node($/)
);
+ # TODO: set $?BLOCK
my $arity := 0;
for $<VAR_NAME> {
my $param := $( $_ );
@@ -540,6 +548,7 @@
}
method class_definition($/) {
+ # TODO: set $?BLOCK
my $past := PAST::Block.new(
:node($/),
:namespace( $<CLASS_NAME><ident> ),
@@ -560,6 +569,7 @@
$past.push( $($_) );
}
+ # TODO: set $?BLOCK
my $methods_block := PAST::Block.new( :blocktype('immediate') );
for $<class_member_definition> {
$methods_block.symbol(
@@ -584,6 +594,7 @@
my $past;
if $key eq 'quote_regex' {
our $?NS;
+ # TODO: set $?BLOCK
$past := PAST::Block.new(
$<quote_regex>,
:compiler('PGE::Perl6Regex'),
Modified: trunk/languages/pipp/src/pct/grammar.pg
==============================================================================
--- trunk/languages/pipp/src/pct/grammar.pg (original)
+++ trunk/languages/pipp/src/pct/grammar.pg Wed Dec 24 04:56:59 2008
@@ -7,9 +7,10 @@
# the starting rule
token TOP {
- {*} #= open
- ^ <sea_or_code>+
- {*} #= close
+ {*} #= open
+ <sea_or_code>*
+ [ $ || <.panic: 'Syntax error'> ]
+ {*} #= close
}
# Whitespace and comments
@@ -34,7 +35,7 @@
# text or PHP-code
token sea_or_code {
- <code_echo_tag> {*} #= code_echo_tag
+ | <code_echo_tag> {*} #= code_echo_tag
| <code_short_tag> {*} #= code_short_tag
| <code_script_tag> {*} #= code_script_tag
| <SEA> {*} #= SEA
Modified: trunk/languages/pipp/src/pipp.pir
==============================================================================
--- trunk/languages/pipp/src/pipp.pir (original)
+++ trunk/languages/pipp/src/pipp.pir Wed Dec 24 04:56:59 2008
@@ -37,20 +37,16 @@
# Pipp uses the Parrot Compiler Toolkit
load_bytecode 'PCT.pbc'
- # %valflags specifies when PAST::Val nodes are allowed to
- # be used as a constant. The 'e' flag indicates that the
- # value must be quoted+escaped in PIR code.
+ # %valflags specifies when PAST::Val nodes are allowed to
+ # be used as a constant. The 'e' flag indicates that the
+ # value must be quoted+escaped in PIR code.
.local pmc valflags
valflags = get_root_global ['parrot';'PAST';'Compiler'], '%valflags'
valflags['PhpString'] = 's~*e'
+ # for accessing config info
load_bytecode 'config.pbc'
- load_bytecode 'PGE.pbc'
- load_bytecode 'PGE/Text.pbc'
- load_bytecode 'PGE/Util.pbc'
- load_bytecode 'PGE/Dumper.pbc'
-
load_bytecode 'P6object.pbc'
# determine location of libs from the Parrot config
@@ -79,8 +75,12 @@
set_hll_global ['Pipp';'Grammar'], 'die', $P0
set_hll_global ['Pipp'], 'die', $P0
+ # Initialize the stack @?BLOCK
+ $P0 = new 'ResizablePMCArray'
+ set_root_global ['parrot';'Pipp';'Grammar';'Actions'], '@?BLOCK', $P0
+
# register and set up the the HLLCompiler
- $P1 = new [ 'PCT';'HLLCompiler' ]
+ $P1 = new ['PCT';'HLLCompiler']
$P1.'language'('Pipp')
$P1.'parsegrammar'('Pipp::Grammar')
$P1.'parseactions'('Pipp::Grammar::Actions')