From e528762c1c59bc0bd0bd6d78246c14269630cf0f Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 15 Mar 2019 12:36:49 +0100 Subject: Switch to bison location tracking Locations for AST nodes are now tracked with the help of bison location tracking. This is more accurate than what we currently do and easier to extend with more information. A zend_ast_loc structure is introduced, which is used for the location stack. Currently it only holds the start lineno, but can be extended to also hold end lineno and offset/column information in the future. All AST constructors now accept a zend_ast_loc* as first argument, and will use it to determine their lineno. Previously this used either the CG(zend_lineno), or the smallest AST lineno of child nodes. On the parser side, the location structure for a whole rule can be obtained using the &@$ character salad. --- Zend/zend_highlight.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Zend/zend_highlight.c') diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c index 5e94df0a99..168a51ca30 100644 --- a/Zend/zend_highlight.c +++ b/Zend/zend_highlight.c @@ -85,13 +85,14 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini { zval token; int token_type; + zend_ast_loc loc; char *last_color = syntax_highlighter_ini->highlight_html; char *next_color; zend_printf(""); zend_printf("\n", last_color); /* highlight stuff coming back from zendlex() */ - while ((token_type=lex_scan(&token, NULL))) { + while ((token_type = lex_scan(&token, NULL, &loc))) { switch (token_type) { case T_INLINE_HTML: next_color = syntax_highlighter_ini->highlight_html; @@ -174,10 +175,11 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini ZEND_API void zend_strip(void) { zval token; + zend_ast_loc loc; int token_type; int prev_space = 0; - while ((token_type=lex_scan(&token, NULL))) { + while ((token_type = lex_scan(&token, NULL, &loc))) { switch (token_type) { case T_WHITESPACE: if (!prev_space) { @@ -193,7 +195,7 @@ ZEND_API void zend_strip(void) case T_END_HEREDOC: zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); /* read the following character, either newline or ; */ - if (lex_scan(&token, NULL) != T_WHITESPACE) { + if (lex_scan(&token, NULL, &loc) != T_WHITESPACE) { zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng)); } zend_write("\n", sizeof("\n") - 1); -- cgit v1.2.1