Skip to content

Commit

Permalink
ignore 'break' statements
Browse files Browse the repository at this point in the history
  • Loading branch information
bschmalhofer committed Mar 25, 2009
1 parent fa40af7 commit dc2e166
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/pct/actions.pm
Expand Up @@ -859,6 +859,10 @@ method param_list($/) {
make $block;
}

method break($/) {
make PAST::Stmts.new( :name('break') );
}

method empty_statement($/) {
make PAST::Stmts.new( :name('empty statement') );
}
Expand Down
8 changes: 6 additions & 2 deletions src/pct/grammar.pg
Expand Up @@ -124,6 +124,7 @@ token close_short_tag {
# statements

rule statement {
| <break> {*} #= break
| <namespace_definition> {*} #= namespace_definition
| <return_statement> {*} #= return_statement
| <require_once_statement> {*} #= require_once_statement
Expand Down Expand Up @@ -163,6 +164,9 @@ rule empty_statement {
';' {*}
}

rule break {
'break' <.statement_delimiter> {*}
}
rule namespace_definition {
'namespace' <namespace_name>? {*} #= open
<block> {*} #= close
Expand Down Expand Up @@ -215,8 +219,8 @@ rule else_clause {
rule switch_statement {
'switch' '(' <expression> ')'
'{'
[ 'case' <literal> ':' <statement_list> ]*
[ 'default' ':' <default=statement_list> ]?
[ 'case' <literal> ':' <statement_list> ]*
[ 'default' ':' <default=statement_list> ]?
'}' {*}
}

Expand Down
5 changes: 5 additions & 0 deletions t/php/control_flow.t
Expand Up @@ -323,6 +323,7 @@ language_output_is( 'Pipp', <<'CODE', '', 'switch, single non-matching case' );
switch (22) {
case 11:
echo 'no match';
break;
}
?>
Expand All @@ -334,6 +335,7 @@ language_output_is( 'Pipp', <<'CODE', 'match', 'switch, single matching case' );
switch (22) {
case 22:
echo 'match';
break;
}
?>
Expand All @@ -345,6 +347,7 @@ language_output_is( 'Pipp', <<'CODE', 'default', 'switch, default case' );
switch (22) {
case 22:
echo 'default';
break;
}
?>
Expand All @@ -356,8 +359,10 @@ language_output_is( 'Pipp', <<'CODE', 'twentytwo', 'switch, two cases' );
switch (22) {
case 21:
echo 'twentyone';
break;
case 22:
echo 'twentytwo';
break;
}
?>
Expand Down

0 comments on commit dc2e166

Please sign in to comment.