Skip to content

Commit fcdb12e

Browse files
committed
Combine SKIP_TOKEN+RETURN_TOKEN into one macro
1 parent c5f1b38 commit fcdb12e

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

Zend/zend_language_scanner.l

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,12 @@ static void copy_heredoc_label_stack(void *void_heredoc_label)
12341234
goto emit_token_with_str; \
12351235
} while (0)
12361236

1237-
#define SKIP_TOKEN(_token) do { \
1237+
#define RETURN_OR_SKIP_TOKEN(_token) do { \
12381238
token = _token; \
1239-
goto skip_token; \
1239+
if (PARSER_MODE()) { \
1240+
goto skip_token; \
1241+
} \
1242+
goto emit_token; \
12401243
} while (0)
12411244

12421245
int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem)
@@ -2025,20 +2028,14 @@ string:
20252028
<INITIAL>"<?php"([ \t]|{NEWLINE}) {
20262029
HANDLE_NEWLINE(yytext[yyleng-1]);
20272030
BEGIN(ST_IN_SCRIPTING);
2028-
if (PARSER_MODE()) {
2029-
SKIP_TOKEN(T_OPEN_TAG);
2030-
}
2031-
RETURN_TOKEN(T_OPEN_TAG);
2031+
RETURN_OR_SKIP_TOKEN(T_OPEN_TAG);
20322032
}
20332033

20342034

20352035
<INITIAL>"<?" {
20362036
if (CG(short_tags)) {
20372037
BEGIN(ST_IN_SCRIPTING);
2038-
if (PARSER_MODE()) {
2039-
SKIP_TOKEN(T_OPEN_TAG);
2040-
}
2041-
RETURN_TOKEN(T_OPEN_TAG);
2038+
RETURN_OR_SKIP_TOKEN(T_OPEN_TAG);
20422039
} else {
20432040
goto inline_char_handler;
20442041
}
@@ -2165,11 +2162,7 @@ inline_char_handler:
21652162
}
21662163

21672164
yyleng = YYCURSOR - SCNG(yy_text);
2168-
2169-
if (PARSER_MODE()) {
2170-
SKIP_TOKEN(T_COMMENT);
2171-
}
2172-
RETURN_TOKEN(T_COMMENT);
2165+
RETURN_OR_SKIP_TOKEN(T_COMMENT);
21732166
}
21742167

21752168
<ST_IN_SCRIPTING>"/*"|"/**"{WHITESPACE} {
@@ -2199,16 +2192,10 @@ inline_char_handler:
21992192

22002193
if (doc_com) {
22012194
CG(doc_comment) = zend_string_init(yytext, yyleng, 0);
2202-
if (PARSER_MODE()) {
2203-
SKIP_TOKEN(T_DOC_COMMENT);
2204-
}
2205-
RETURN_TOKEN(T_DOC_COMMENT);
2195+
RETURN_OR_SKIP_TOKEN(T_DOC_COMMENT);
22062196
}
22072197

2208-
if (PARSER_MODE()) {
2209-
SKIP_TOKEN(T_COMMENT);
2210-
}
2211-
RETURN_TOKEN(T_COMMENT);
2198+
RETURN_OR_SKIP_TOKEN(T_COMMENT);
22122199
}
22132200

22142201
<ST_IN_SCRIPTING>"?>"{NEWLINE}? {

0 commit comments

Comments
 (0)