Author: bernhard
Date: Sat Dec 27 09:04:11 2008
New Revision: 34430
Modified:
trunk/languages/pipp/src/pct/actions.pm
trunk/languages/pipp/src/pct/grammar.pg
Log:
[Pipp] Add rule <statement_list> in order to simplify actions.
Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm (original)
+++ trunk/languages/pipp/src/pct/actions.pm Sat Dec 27 09:04:11 2008
@@ -72,50 +72,41 @@
}
method code_short_tag($/) {
- my $past := PAST::Stmts.new( :node($/) );
- for $<statement> {
- $past.push( $($_) );
- }
-
- make $past;
+ make $( $<statement_list> );
}
method code_echo_tag($/) {
- my $past := PAST::Stmts.new( :node($/) );
+ my $stmts := $( $<statement_list> );
my $echo := $( $<arguments> );
$echo.name( 'echo' );
- $past.push( $echo );
- for $<statement> {
- $past.push( $($_) );
- }
+ $stmts.unshift( $echo );
- make $past;
+ make $stmts;
}
method code_script_tag($/) {
- my $past := PAST::Stmts.new( :node($/) );
- for $<statement> {
- $past.push( $($_) );
- }
-
- make $past;
+ make $( $<statement_list> );
}
method block($/) {
- my $past := PAST::Stmts.new( :node($/) );
- for $<statement> {
- $past.push( $($_) );
- }
-
- make $past;
+ make $( $<statement_list> );
}
method statement($/, $key) {
make $( $/{$key} );
}
+method statement_list($/) {
+ my $stmts := PAST::Stmts.new( :node($/) );
+ for $<statement> {
+ $stmts.push( $($_) );
+ }
+
+ make $stmts;
+}
+
method inline_sea_short_tag($/) {
make PAST::Op.new(
PAST::Val.new(
Modified: trunk/languages/pipp/src/pct/grammar.pg
==============================================================================
--- trunk/languages/pipp/src/pct/grammar.pg (original)
+++ trunk/languages/pipp/src/pct/grammar.pg Sat Dec 27 09:04:11 2008
@@ -49,21 +49,21 @@
rule code_echo_tag {
<.CODE_START_ECHO_TAG> <arguments> <.statement_delimiter>
- <statement>*
+ <statement_list>
<.close_short_tag>?
{*}
}
rule code_script_tag {
<.open_script_tag>
- <statement>*
+ <statement_list>
<.close_script_tag>?
{*}
}
rule code_short_tag {
<.open_short_tag>
- <statement>*
+ <statement_list>
<.close_short_tag>?
{*}
}
@@ -118,7 +118,7 @@
# block and statements
rule block {
- '{' <statement>* '}'
+ '{' <statement_list> '}'
{*}
}
@@ -139,6 +139,10 @@
| <class_definition> {*} #= class_definition
}
+rule statement_list {
+ <statement>* {*}
+}
+
rule statement_delimiter {
';'
| <before '?'>