Permalink
Browse files

Fix special case of alternate if statements

Summary:
Fixes #8185

```
if (0):
endif;
```
no longer parses a missing if body

Reviewed By: oulgen

Differential Revision: D7916752
  • Loading branch information...
vassilmladenov authored and fredemmott committed May 9, 2018
1 parent f639612 commit 94e18795f021193431ef3c687868a3dd245440a5
@@ -866,10 +866,17 @@ module WithParser(Parser : Parser_S) = struct
parse_list_while parser parse_item predicate
let parse_alternate_if_block parser parse_item =
parse_list_while parser parse_item (fun parser ->
let parser1, block = parse_list_while parser parse_item (fun parser ->
match peek_token_kind parser with
| TokenKind.Elseif | TokenKind.Else | TokenKind.Endif -> false
| _ -> true)
| _ -> true) in
if SC.is_missing block
then
let parser, empty = Make.missing parser (pos parser) in
let parser, es = Make.expression_statement parser empty empty in
make_list parser [es]
else
parser1, block
let parse_list_until_none parser parse_item =
let rec aux parser acc =
@@ -0,0 +1,4 @@
<?php
if (0):
endif;
@@ -0,0 +1,14 @@
((script 21
((list 21
((markup_section 5
((missing 0 ()) (() markup 0 ())
(markup_suffix 5 ((() <? 2 ()) (() name 3 ((end_of_line 1)))))
(missing 0 ())))
(alternate_if_statement 14
((((end_of_line 1)) if 2 ((whitespace 1))) (() "(" 1 ())
(literal 1 ((() octal_literal 1 ()))) (() ")" 1 ())
(() : 1 ((end_of_line 1)))
(list 0 ((expression_statement 0 ((missing 0 ()) (missing 0 ())))))
(missing 0 ()) (missing 0 ()) (() endif 5 ())
(() ";" 1 ((end_of_line 1)))))
(end_of_file 0 ((() end_of_file 0 ()))))))))

0 comments on commit 94e1879

Please sign in to comment.