summaryrefslogtreecommitdiff
path: root/ext/tokenizer/tokenizer.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-03-28 09:29:08 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-03-28 09:29:08 +0100
commit7f72d771e8581bfff7856b46ae9fb8555b061118 (patch)
tree0498b0673b6eefb1ee6b5878b4141b840dfa2aef /ext/tokenizer/tokenizer.c
parentbcb99a3bf778f00af8c6a61e612eb5384280657a (diff)
downloadphp-git-7f72d771e8581bfff7856b46ae9fb8555b061118.tar.gz
Revert "Switch to bison location tracking"
This reverts commit e528762c1c59bc0bd0bd6d78246c14269630cf0f. Dmitry reports that this has a non-trivial impact on parsing overhead, especially on 32-bit systems. As we don't have a strong need for this change right now, I'm reverting it. See also comments on https://github.com/php/php-src/commit/e528762c1c59bc0bd0bd6d78246c14269630cf0f.
Diffstat (limited to 'ext/tokenizer/tokenizer.c')
-rw-r--r--ext/tokenizer/tokenizer.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c
index 6d671f47e3..91ace6f701 100644
--- a/ext/tokenizer/tokenizer.c
+++ b/ext/tokenizer/tokenizer.c
@@ -127,8 +127,8 @@ static zend_bool tokenize(zval *return_value, zend_string *source)
zval source_zval;
zend_lex_state original_lex_state;
zval token;
- zend_ast_loc loc;
int token_type;
+ int token_line = 1;
int need_tokens = -1; /* for __halt_compiler lexing. -1 = disabled */
ZVAL_STR_COPY(&source_zval, source);
@@ -142,8 +142,8 @@ static zend_bool tokenize(zval *return_value, zend_string *source)
LANG_SCNG(yy_state) = yycINITIAL;
array_init(return_value);
- while ((token_type = lex_scan(&token, NULL, &loc))) {
- add_token(return_value, token_type, zendtext, zendleng, loc.start_line);
+ while ((token_type = lex_scan(&token, NULL))) {
+ add_token(return_value, token_type, zendtext, zendleng, token_line);
if (Z_TYPE(token) != IS_UNDEF) {
zval_ptr_dtor_nogc(&token);
@@ -159,13 +159,20 @@ static zend_bool tokenize(zval *return_value, zend_string *source)
/* fetch the rest into a T_INLINE_HTML */
if (zendcursor != zendlimit) {
add_token(return_value, T_INLINE_HTML,
- zendcursor, zendlimit - zendcursor, loc.start_line);
+ zendcursor, zendlimit - zendcursor, token_line);
}
break;
}
} else if (token_type == T_HALT_COMPILER) {
need_tokens = 3;
}
+
+ if (CG(increment_lineno)) {
+ CG(zend_lineno)++;
+ CG(increment_lineno) = 0;
+ }
+
+ token_line = CG(zend_lineno);
}
zval_ptr_dtor_str(&source_zval);