[svn:parrot] r39839 - in branches/pmc_pct/compilers/pmcc/src: emitter parser
cotto at svn.parrot.org
cotto at svn.parrot.org
Tue Jun 30 05:13:18 UTC 2009
Author: cotto
Date: Tue Jun 30 05:13:17 2009
New Revision: 39839
URL: https://trac.parrot.org/parrot/changeset/39839
Log:
[pmcc] Simplify function body parsing to slurp everything into a PAST::Block.
The next step is to change the emitter code to apply a bunch of regexes similar to what pmc2c does.
NOTE: This may be the last commit to this branch, as a separate pmc compiler may not be necessary. See http://irclog.perlgeek.de/parrot/2009-06-30#i_1275754
Modified:
branches/pmc_pct/compilers/pmcc/src/emitter/c.pm
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/emitter/c.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/emitter/c.pm Tue Jun 30 04:43:21 2009 (r39838)
+++ branches/pmc_pct/compilers/pmcc/src/emitter/c.pm Tue Jun 30 05:13:17 2009 (r39839)
@@ -21,9 +21,6 @@
method rewrite_macro($pmclass, $past) {
my $res;
- if $past<is_self> {
- $res := "VTABLE_" ~ $past.name ~ '(' ~ arguments($past) ~')';
- }
$res;
}
Modified: branches/pmc_pct/compilers/pmcc/src/parser/actions.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/parser/actions.pm Tue Jun 30 04:43:21 2009 (r39838)
+++ branches/pmc_pct/compilers/pmcc/src/parser/actions.pm Tue Jun 30 05:13:17 2009 (r39839)
@@ -253,12 +253,10 @@
method c_body($/) {
#say("c_body: " ~ $/);
- my $past := PAST::Stmts.new(
+ my $past := PAST::Block.new(
:node($/),
+ ~$/
);
- for $<c_body_statement> {
- $past.push($_.ast);
- }
make $past;
}
@@ -280,62 +278,6 @@
make $past;
}
-method c_body_statement($/, $key) {
- my $past;
- #say("body " ~ $key);
- if ($key eq 'characters') {
- $past := PAST::Op.new(
- :node($/),
- :pasttype('inline'),
- :inline(~$/)
- );
- }
- elsif ($key eq 'macro') {
- $past := $<c_body_macro>.ast;
- }
- elsif ($key eq 'body') {
- $past := $<c_body>.ast;
- }
- else {
- $/.panic("Unknown key " ~ $key);
- }
-
- make $past;
-}
-
-method c_body_macro($/, $key) {
- my $past;
- $past := PAST::Op.new(
- :name(~$<identifier>),
- :pasttype('call'),
- :node($/)
- );
-
- $past<is_macro> := 1;
- $past<is_self> := $key eq 'SELF';
- $past<is_super> := $key eq 'SUPER';
-
- my $params := ~$<c_parameters><c_parameter>;
- #say("PARAMS " ~ $params);
- if $params {
- $past.push(
- PAST::Val.new(
- :value($params)
- )
- );
- }
-
- make $past;
-}
-
-method c_parameter($/) {
- #say("c_parameters " ~ $/);
- make PAST::Val.new(
- :node($/),
- :value(~$/)
- );
-}
-
# Local Variables:
# mode: pir
# fill-column: 100
Modified: branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg Tue Jun 30 04:43:21 2009 (r39838)
+++ branches/pmc_pct/compilers/pmcc/src/parser/grammar.pg Tue Jun 30 05:13:17 2009 (r39839)
@@ -140,36 +140,11 @@
# Nested list of something
rule c_body {
- '{' <c_body_statement>* '}' {*}
+ '{' <c_body_statement>+? '}' {*}
}
rule c_body_statement {
- | <c_body_macro> {*} #= macro
- | <-[{}]>+ {*} #= characters
- | <c_body> {*} #= body
-}
-
-# Various macros for VTABLE body
-rule c_body_macro {
- | 'SELF.' :: [ <identifier> '(' <c_parameters>? ')' || <.panic: "Syntax error in SELF macro"> ]
- {*} #= SELF
- | '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>? ')'
+ <-[{}]>+ | <c_body>
}
# It's really bad signature
More information about the parrot-commits
mailing list