Skip to content
This repository
Browse code

[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...
commit fff00f72a939917714bbaf2f9135883ae696df4b 1 parent c09d924
cotto authored
3  compilers/pmcc/src/emitter/c.pm
@@ -21,9 +21,6 @@ method rewrite_op($pmclass, $past) {
21 21
22 22 method rewrite_macro($pmclass, $past) {
23 23 my $res;
24   - if $past<is_self> {
25   - $res := "VTABLE_" ~ $past.name ~ '(' ~ arguments($past) ~')';
26   - }
27 24
28 25 $res;
29 26 }
62 compilers/pmcc/src/parser/actions.pm
@@ -253,12 +253,10 @@ sub cleanup_type($type) {
253 253
254 254 method c_body($/) {
255 255 #say("c_body: " ~ $/);
256   - my $past := PAST::Stmts.new(
  256 + my $past := PAST::Block.new(
257 257 :node($/),
  258 + ~$/
258 259 );
259   - for $<c_body_statement> {
260   - $past.push($_.ast);
261   - }
262 260 make $past;
263 261 }
264 262
@@ -280,62 +278,6 @@ method c_argument($/) {
280 278 make $past;
281 279 }
282 280
283   -method c_body_statement($/, $key) {
284   - my $past;
285   - #say("body " ~ $key);
286   - if ($key eq 'characters') {
287   - $past := PAST::Op.new(
288   - :node($/),
289   - :pasttype('inline'),
290   - :inline(~$/)
291   - );
292   - }
293   - elsif ($key eq 'macro') {
294   - $past := $<c_body_macro>.ast;
295   - }
296   - elsif ($key eq 'body') {
297   - $past := $<c_body>.ast;
298   - }
299   - else {
300   - $/.panic("Unknown key " ~ $key);
301   - }
302   -
303   - make $past;
304   -}
305   -
306   -method c_body_macro($/, $key) {
307   - my $past;
308   - $past := PAST::Op.new(
309   - :name(~$<identifier>),
310   - :pasttype('call'),
311   - :node($/)
312   - );
313   -
314   - $past<is_macro> := 1;
315   - $past<is_self> := $key eq 'SELF';
316   - $past<is_super> := $key eq 'SUPER';
317   -
318   - my $params := ~$<c_parameters><c_parameter>;
319   - #say("PARAMS " ~ $params);
320   - if $params {
321   - $past.push(
322   - PAST::Val.new(
323   - :value($params)
324   - )
325   - );
326   - }
327   -
328   - make $past;
329   -}
330   -
331   -method c_parameter($/) {
332   - #say("c_parameters " ~ $/);
333   - make PAST::Val.new(
334   - :node($/),
335   - :value(~$/)
336   - );
337   -}
338   -
339 281 # Local Variables:
340 282 # mode: pir
341 283 # fill-column: 100
29 compilers/pmcc/src/parser/grammar.pg
@@ -140,36 +140,11 @@ rule method_attr {
140 140
141 141 # Nested list of something
142 142 rule c_body {
143   - '{' <c_body_statement>* '}' {*}
  143 + '{' <c_body_statement>+? '}' {*}
144 144 }
145 145
146 146 rule c_body_statement {
147   - | <c_body_macro> {*} #= macro
148   - | <-[{}]>+ {*} #= characters
149   - | <c_body> {*} #= body
150   -}
151   -
152   -# Various macros for VTABLE body
153   -rule c_body_macro {
154   - | 'SELF.' :: [ <identifier> '(' <c_parameters>? ')' || <.panic: "Syntax error in SELF macro"> ]
155   - {*} #= SELF
156   - | 'SUPER' :: '(' <c_parameters>? ')'
157   - {*} #= SUPER
158   -}
159   -
160   -# We don't parse parameters. We are PMC, not C99 compiler (yet).
161   -# FIXME Instead of "<-[()]>" it should be something meaningful.
162   -rule c_parameters {
163   - [ <c_parameter> [ ',' <c_parameter> ]* ]
164   -}
165   -
166   -rule c_parameter {
167   - <-[()]>+ <c_parameters_parens>?
168   - {*}
169   -}
170   -
171   -rule c_parameters_parens {
172   - '(' <c_parameters>? ')'
  147 + <-[{}]>+ | <c_body>
173 148 }
174 149
175 150 # It's really bad signature

0 comments on commit fff00f7

Please sign in to comment.
Something went wrong with that request. Please try again.