Skip to content

Commit d1585a9

Browse files
committed
Revert "Handle scanner error in first place (don't hide them from ext/tokenizer) and cheaper whitespace handlig."
This reverts commit 0d6da03.
1 parent 0d6da03 commit d1585a9

File tree

6 files changed

+233
-252
lines changed

6 files changed

+233
-252
lines changed

Zend/zend_compile.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,16 +1690,25 @@ int zendlex(zend_parser_stack_elem *elem) /* {{{ */
16901690
ZVAL_UNDEF(&zv);
16911691
start_lineno = CG(zend_lineno);
16921692
retval = lex_scan(&zv);
1693+
if (EG(exception)) {
1694+
return T_ERROR;
1695+
}
16931696

1694-
if (retval >= T_WHITESPACE) {
1695-
if (EXPECTED(retval < T_OPEN_TAG_WITH_ECHO)) {
1697+
switch (retval) {
1698+
case T_COMMENT:
1699+
case T_DOC_COMMENT:
1700+
case T_OPEN_TAG:
1701+
case T_WHITESPACE:
16961702
goto again;
1697-
} else if (retval == T_OPEN_TAG_WITH_ECHO) {
1698-
retval = T_ECHO;
1699-
} else if (retval == T_CLOSE_TAG) {
1703+
1704+
case T_CLOSE_TAG:
17001705
retval = ';'; /* implicit ; */
1701-
}
1702-
} else if (Z_TYPE(zv) != IS_UNDEF) {
1706+
break;
1707+
case T_OPEN_TAG_WITH_ECHO:
1708+
retval = T_ECHO;
1709+
break;
1710+
}
1711+
if (Z_TYPE(zv) != IS_UNDEF) {
17031712
elem->ast = zend_ast_create_zval_with_lineno(&zv, 0, start_lineno);
17041713
}
17051714

Zend/zend_language_parser.y

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
203203
%token T_TRAIT_C "__TRAIT__ (T_TRAIT_C)"
204204
%token T_METHOD_C "__METHOD__ (T_METHOD_C)"
205205
%token T_FUNC_C "__FUNCTION__ (T_FUNC_C)"
206+
%token T_COMMENT "comment (T_COMMENT)"
207+
%token T_DOC_COMMENT "doc comment (T_DOC_COMMENT)"
208+
%token T_OPEN_TAG "open tag (T_OPEN_TAG)"
209+
%token T_OPEN_TAG_WITH_ECHO "open tag with echo (T_OPEN_TAG_WITH_ECHO)"
210+
%token T_CLOSE_TAG "close tag (T_CLOSE_TAG)"
211+
%token T_WHITESPACE "whitespace (T_WHITESPACE)"
206212
%token T_START_HEREDOC "heredoc start (T_START_HEREDOC)"
207213
%token T_END_HEREDOC "heredoc end (T_END_HEREDOC)"
208214
%token T_DOLLAR_OPEN_CURLY_BRACES "${ (T_DOLLAR_OPEN_CURLY_BRACES)"
@@ -216,14 +222,6 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
216222
%token T_POW "** (T_POW)"
217223
%token T_POW_EQUAL "**= (T_POW_EQUAL)"
218224

219-
/* Special tokens (ignorred by PHP compiler, T_WHITESPACE must be first) */
220-
%token T_WHITESPACE "whitespace (T_WHITESPACE)"
221-
%token T_COMMENT "comment (T_COMMENT)"
222-
%token T_DOC_COMMENT "doc comment (T_DOC_COMMENT)"
223-
%token T_OPEN_TAG "open tag (T_OPEN_TAG)"
224-
%token T_OPEN_TAG_WITH_ECHO "open tag with echo (T_OPEN_TAG_WITH_ECHO)"
225-
%token T_CLOSE_TAG "close tag (T_CLOSE_TAG)"
226-
227225
/* Token used to force a parse error from the lexer */
228226
%token T_ERROR
229227

0 commit comments

Comments
 (0)