Re: token_get_all(): additional location information, and raw tokens
| From: | Derick Rethans | Date: | Wed, 06 Jan 2016 09:22:44 +0000 |
| Subject: | Re: token_get_all(): additional location information, and raw tokens | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-90188@lists.php.net to get a copy of this message | ||
On Tue, 5 Jan 2016, Fred Emmott wrote:
> I’m planning on adding this functionality in some form to HHVM,
> however if it’s also wanted in PHP, I’d rather not add something
> HHVM-specific and will be happy to put up RFCs :)
>
> Location Information
> ————
>
> token_get_all() returns a line number for some tokens. I propose
> adding an additional TOKEN_EXTENDED_LOCATION flag, that would include:
>
> - starting line and character number within that line
> - ending line and character number within that line
That'd be nice to have... but I don't think the parser keeps that
information currently.
> T_ENCAPSED_AND_WHITESPACE and T_INLINE_HTML seem to be the most common
> cases of start line !== end line.
I would probably only include the ending line number if it is different?
Saves on a whole lot of memory allocations and usage... and it's trivial
to detect in consuming code.
cheers,
Derick