develooper Front page | perl.cvs.parrot | Postings from January 2009

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

From:
bernhard
Date:
January 20, 2009 07:34
Subject:
[svn:parrot] r35811 - trunk/languages/pipp/src/pct
Message ID:
20090120153446.57C82CB9AE@x12.develooper.com
Author: bernhard
Date: Tue Jan 20 07:34:45 2009
New Revision: 35811

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

Log:
[Pipp] Use class_member_or_method_definition as a wrapper for stuff
inside a class definition

Modified: trunk/languages/pipp/src/pct/actions.pm
==============================================================================
--- trunk/languages/pipp/src/pct/actions.pm	(original)
+++ trunk/languages/pipp/src/pct/actions.pm	Tue Jan 20 07:34:45 2009
@@ -775,15 +775,7 @@
         my $block := @?BLOCK.shift();
 
         # setup of class constants is done in the 'loadinit' node
-        for $<constant_definition> {
-            $block.push( $($_) );
-        }
-
-        # declare the attributes
-        for $<class_member_definition> {
-            $block.push( $($_) );
-        }
-        for $<class_static_member_definition> {
+        for $<class_member_or_method_definition> {
             $block.push( $($_) );
         }
 
@@ -812,17 +804,15 @@
             )
         );
 
-        # add the methods
-        for $<class_method_definition> {
-            $block.push( $($_) );
-        }
-
         $?CLASS := '';
 
         make $block;
     }
 }
 
+method class_member_or_method_definition($/, $key) {
+    make $( $/{$key} );
+}
 
 method quote($/) {
     make $( $<quote_expression> );

Modified: trunk/languages/pipp/src/pct/grammar.pg
==============================================================================
--- trunk/languages/pipp/src/pct/grammar.pg	(original)
+++ trunk/languages/pipp/src/pct/grammar.pg	Tue Jan 20 07:34:45 2009
@@ -440,13 +440,14 @@
 
 rule class_definition {
     'class' <class_name> [ 'implements' <interface_name> ]?  {*}  #= open
-    '{'
-        [ | <constant_definition>
-          | <class_member_definition>
-          | <class_static_member_definition>
-          | <class_method_definition>
-        ]*
-    '}'                                                      {*}  #= close
+    '{' <class_member_or_method_definition>* '}'             {*}  #= close
+}
+
+rule class_member_or_method_definition {
+    | <constant_definition> {*}                  #= constant_definition
+    | <class_member_definition> {*}              #= class_member_definition
+    | <class_static_member_definition> {*}       #= class_static_member_definition
+    | <class_method_definition> {*}              #= class_method_definition
 }
 
 # In PHP 5.3 a constant definition outside a declared namespace or class is forbidden



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