develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34432 - trunk/languages/pipp/src/pct

From:
bernhard
Date:
December 27, 2008 09:35
Subject:
[svn:parrot] r34432 - trunk/languages/pipp/src/pct
Message ID:
20081227173537.E2E40CBA12@x12.develooper.com
Author: bernhard
Date: Sat Dec 27 09:35:37 2008
New Revision: 34432

Modified:
   trunk/languages/pipp/src/pct/actions.pm
   trunk/languages/pipp/src/pct/grammar.pg

Log:
[Pipp] Eliminate rule block in favour of statement_list.


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:35:37 2008
@@ -62,12 +62,12 @@
 # The sea, text, surrounding the island, code, is printed out
 method SEA($/) {
     make PAST::Op.new(
+             :name('echo'),
+             :node($/),
              PAST::Val.new(
                  :value(~$/),
                  :returns('PhpString')
-             ),
-             :name('echo'),
-             :node($/)
+             )
          );
 }
 
@@ -90,10 +90,6 @@
     make $( $<statement_list> );
 }
 
-method block($/) {
-    make $( $<statement_list> );
-}
-
 method statement($/, $key) {
     make $( $/{$key} );
 }
@@ -285,22 +281,22 @@
 }
 
 method conditional_expression($/) {
-    my $past := PAST::Op.new(
-                    $( $<expression> ),
-                    $( $<block> ),
-                    :node($/)
-                );
-    make $past;
+    make
+        PAST::Op.new(
+            :node($/),
+            $( $<expression> ),
+            $( $<statement_list> )
+        );
 }
 
 method do_while_statement($/) {
-    my $past := PAST::Op.new(
-                    $( $<expression> ),
-                    $( $<block> ),
-                    :pasttype('repeat_while'),
-                    :node($/)
-                );
-    make $past;
+    make
+        PAST::Op.new(
+            :pasttype('repeat_while'),
+            :node($/),
+            $( $<expression> ),
+            $( $<statement_list> )
+        );
 }
 
 method if_statement($/) {
@@ -309,7 +305,7 @@
         
     my $else := undef;
     if +$<else_clause> {
-        $else := $( $<else_clause>[0] );
+        $else := $( $<else_clause>[0]<statement_list> );
     }
     my $first_eif := undef;
     if +$<elseif_clause> {
@@ -339,10 +335,6 @@
      make $past;
 }
 
-method else_clause($/) {
-    make $( $<block> );
-}
-
 method elseif_clause($/) {
     my $past := $( $<conditional_expression> );
     $past.pasttype('if');
@@ -432,9 +424,9 @@
 
 method for_statement($/) {
     my $init  := $( $<var_assign> );
+
     my $cond  := $( $<expression>[0] );
-    my $work  := PAST::Stmts.new( $( $<block> ), $( $<expression>[1] ) );
-    
+    my $work  := PAST::Stmts.new( $( $<statement_list> ), $( $<expression>[1] ) );
     my $while := PAST::Op.new(
                        $cond,
                        $work,
@@ -525,7 +517,7 @@
 
         $block.name( ~$<FUNCTION_NAME> );
         $block.control('return_pir');
-        $block.push( $( $<block> ) );
+        $block.push( $( $<statement_list> ) );
 
         make $block;
     }
@@ -560,7 +552,7 @@
         $block.name( ~$<METHOD_NAME> );
         $block.blocktype( 'method' );
         $block.control('return_pir');
-        $block.push( $( $<block> ) );
+        $block.push( $( $<statement_list> ) );
 
         make $block;
     }

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:35:37 2008
@@ -116,14 +116,10 @@
     }} <.fail>
 }
 
-# block and statements
-rule block {
-    '{' <statement_list> '}'
-    {*}
-}
+# statements
 
 rule statement {
-      <namespace_statement>     {*}  #= namespace_statement
+    | <namespace_statement>     {*}  #= namespace_statement
     | <return_statement>        {*}  #= return_statement
     | <require_once_statement>  {*}  #= require_once_statement
     | <echo_statement>          {*}  #= echo_statement
@@ -144,7 +140,7 @@
 }
 
 rule statement_delimiter {
-      ';'
+    | ';'
     | <before '?'>
     | $
 }
@@ -181,7 +177,7 @@
 }
 
 rule conditional_expression {
-    '(' <expression> ')' <block>
+    '(' <expression> ')' '{' <statement_list> '}'
     {*}
 }
 
@@ -193,8 +189,7 @@
 }
 
 rule else_clause {
-    'else' <block>
-    {*}
+    'else' '{' <statement_list> '}'
 }
 
 rule elseif_clause {
@@ -208,12 +203,12 @@
 }
 
 rule do_while_statement {
-    'do' <block> 'while' '(' <expression> ')' <.statement_delimiter>
+    'do' '{' <statement_list> '}' 'while' '(' <expression> ')' <.statement_delimiter>
     {*}
 }
 
 rule for_statement {
-    'for' '(' <var_assign> <expression> ';' <expression> ')' <block>
+    'for' '(' <var_assign> <expression> ';' <expression> ')' '{' <statement_list> '}'
     {*}
 }
 
@@ -393,7 +388,7 @@
 rule function_definition {
     'function' <FUNCTION_NAME> <param_list>
     {*}                                     #= open
-    <block>
+    '{' <statement_list> '}'
     {*}                                     #= close
 }
 
@@ -438,7 +433,7 @@
 rule class_method_definition {
     'function' <METHOD_NAME> <param_list>
     {*}                                     #= open
-    <block>
+    '{' <statement_list> '}'
     {*}                                     #= close
 }
 



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