Permalink
Browse files

[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


git-svn-id: https://svn.parrot.org/parrot/branches/pmc_pct@39839 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent c09d924 commit fff00f72a939917714bbaf2f9135883ae696df4b cotto committed Jun 30, 2009
Showing with 4 additions and 90 deletions.
  1. +0 −3 compilers/pmcc/src/emitter/c.pm
  2. +2 −60 compilers/pmcc/src/parser/actions.pm
  3. +2 −27 compilers/pmcc/src/parser/grammar.pg
View
3 compilers/pmcc/src/emitter/c.pm
@@ -21,9 +21,6 @@ method rewrite_op($pmclass, $past) {
method rewrite_macro($pmclass, $past) {
my $res;
- if $past<is_self> {
- $res := "VTABLE_" ~ $past.name ~ '(' ~ arguments($past) ~')';
- }
$res;
}
View
62 compilers/pmcc/src/parser/actions.pm
@@ -253,12 +253,10 @@ sub cleanup_type($type) {
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 @@ method c_argument($/) {
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
View
29 compilers/pmcc/src/parser/grammar.pg
@@ -140,36 +140,11 @@ rule method_attr {
# 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

0 comments on commit fff00f7

Please sign in to comment.