Skip to content

Instantly share code, notes, and snippets.

@sgolemon
Created November 10, 2014 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgolemon/1e030d03d6445694a9b5 to your computer and use it in GitHub Desktop.
Save sgolemon/1e030d03d6445694a9b5 to your computer and use it in GitHub Desktop.
diff --git a/hphp/parser/hphp.y b/hphp/parser/hphp.y
--- a/hphp/parser/hphp.y
+++ b/hphp/parser/hphp.y
@@ -887,17 +887,8 @@
| class_declaration_statement { $$ = $1;}
| trait_declaration_statement { $$ = $1;}
;
-statement:
+statement_no_if:
'{' inner_statement_list '}' { _p->onBlock($$, $2);}
- | T_IF parenthesis_expr
- statement
- elseif_list
- else_single { _p->onIf($$,$2,$3,$4,$5);}
- | T_IF parenthesis_expr ':'
- inner_statement_list
- new_elseif_list
- new_else_single
- T_ENDIF ';' { _p->onIf($$,$2,$4,$5,$6);}
| T_WHILE parenthesis_expr { _p->onNewLabelScope(false);
_p->pushLabelScope();}
while_statement { _p->popLabelScope();
@@ -984,6 +975,19 @@
_p->onScopeLabel($$, $1);}
;
+statement:
+ statement_no_if
+ | T_IF parenthesis_expr
+ statement
+ elseif_list
+ else_single { _p->onIf($$,$2,$3,$4,$5);}
+ | T_IF parenthesis_expr ':'
+ inner_statement_list
+ new_elseif_list
+ new_else_single
+ T_ENDIF ';' { _p->onIf($$,$2,$4,$5,$6);}
+;
+
try_statement_list:
'{' { _p->onNewLabelScope(false);}
inner_statement_list '}' { $$ = $3;}
@@ -1253,19 +1257,24 @@
| ';' { $$.reset();}
;
+elseif_token:
+ T_ELSEIF
+ | T_ELSE T_IF
+;
+
elseif_list:
- elseif_list T_ELSEIF parenthesis_expr
+ elseif_list elseif_token parenthesis_expr
statement { _p->onElseIf($$,$1,$3,$4);}
| { $$.reset();}
;
new_elseif_list:
- new_elseif_list T_ELSEIF
+ new_elseif_list elseif_token
parenthesis_expr ':'
inner_statement_list { _p->onElseIf($$,$1,$3,$5);}
| { $$.reset();}
;
else_single:
- T_ELSE statement { $$ = $2;}
+ T_ELSE statement_no_if { $$ = $2;}
| { $$.reset();}
;
new_else_single:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment