Skip to content

Commit

Permalink
Remove the abstraction 'conditional_expression', be more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
bschmalhofer committed Feb 22, 2009
1 parent 0640605 commit 4d3519a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
35 changes: 18 additions & 17 deletions src/pct/actions.pm
Expand Up @@ -368,13 +368,6 @@ method argument_list($/) {
make $past;
}

method conditional_expression($/) {
make PAST::Op.new(
:node($/),
$( $<expression> ),
$( $<block> )
);
}

method do_while_statement($/) {
make PAST::Op.new(
Expand All @@ -386,8 +379,12 @@ method do_while_statement($/) {
}

method if_statement($/) {
my $past := $( $<conditional_expression> );
$past.pasttype('if');
my $past := PAST::Op.new(
:node($/),
:pasttype('if'),
$( $<expression> ),
$( $<block> )
);

my $else := undef;
if +$<else_clause> {
Expand Down Expand Up @@ -422,10 +419,12 @@ method if_statement($/) {
}

method elseif_clause($/) {
my $past := $( $<conditional_expression> );
$past.pasttype('if');

make $past;
make PAST::Op.new(
:node($/),
:pasttype('if'),
$( $<expression> ),
$( $<block> )
);
}

method switch_statement($/) {
Expand Down Expand Up @@ -514,10 +513,12 @@ method member($/) {
}

method while_statement($/) {
my $past := $( $<conditional_expression> );
$past.pasttype('while');

make $past;
make PAST::Op.new(
:node($/),
:pasttype('while'),
$( $<expression> ),
$( $<block> )
);
}

method for_statement($/) {
Expand Down
11 changes: 3 additions & 8 deletions src/pct/grammar.pg
Expand Up @@ -199,13 +199,8 @@ rule argument_list {
{*}
}

rule conditional_expression {
'(' <expression> ')' <block>
{*}
}

rule if_statement {
'if' <conditional_expression>
'if' '(' <expression> ')' <block>
<elseif_clause>*
<else_clause>?
{*}
Expand All @@ -221,12 +216,12 @@ rule switch_statement {
}

rule elseif_clause {
'elseif' <conditional_expression>
'elseif' '(' <expression> ')' <block>
{*}
}

rule while_statement {
'while' <conditional_expression>
'while' '(' <expression> ')' <block>
{*}
}

Expand Down

0 comments on commit 4d3519a

Please sign in to comment.