[svn:parrot] r38685 - branches/pmc_pct/compilers/pmcc/src/parser

bacek at svn.parrot.org bacek at svn.parrot.org
Mon May 11 12:11:55 UTC 2009


Author: bacek
Date: Mon May 11 12:11:54 2009
New Revision: 38685
URL: https://trac.parrot.org/parrot/changeset/38685

Log:
Improve parsing of parameters in MACRO calls

Modified:
   branches/pmc_pct/compilers/pmcc/src/parser/actions.pm
   branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg

Modified: branches/pmc_pct/compilers/pmcc/src/parser/actions.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/parser/actions.pm	Mon May 11 11:24:58 2009	(r38684)
+++ branches/pmc_pct/compilers/pmcc/src/parser/actions.pm	Mon May 11 12:11:54 2009	(r38685)
@@ -203,15 +203,20 @@
     $past<is_self>  := $key eq 'SELF';
     $past<is_super> := $key eq 'SUPER';
 
-    #say("PARAMS " ~ $<c_parameters>);
-    for $<c_parameters> {
-        $past.push($_.ast);
+    my $params := ~$<c_parameters><c_parameter>;
+    #say("PARAMS " ~ $params);
+    if $params {
+        $past.push(
+            PAST::Val.new(
+                :value($params)
+            )
+        );
     }
 
     make $past;
 }
 
-method c_parameters($/) {
+method c_parameter($/) {
     #say("c_parameters " ~ $/);
     make PAST::Val.new(
         :node($/),

Modified: branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg	Mon May 11 11:24:58 2009	(r38684)
+++ branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg	Mon May 11 12:11:54 2009	(r38685)
@@ -145,14 +145,23 @@
 rule c_body_macro {
     | 'SELF.' :: [ <identifier> '(' <c_parameters>? ')' || <.panic: "Syntax error in SELF macro"> ]
       {*} #= SELF
-    | 'SUPER' :: '(' <c_parameters> ')'
+    | 'SUPER' :: '(' <c_parameters>? ')'
       {*} #= SUPER
 }
 
 # We don't parse parameters. We are PMC, not C99 compiler (yet).
 # FIXME Instead of "<-[()]>" it should be something meaningful.
 rule c_parameters {
-    <-[()]>+ {*}
+    [ <c_parameter> [ ',' <c_parameter> ]* ]
+}
+
+rule c_parameter {
+    <-[()]>+ <c_parameters_parens>? 
+    {*}
+}
+
+rule c_parameters_parens {
+    '(' <c_parameters>? ')'
 }
 
 # It's really bad signature


More information about the parrot-commits mailing list