You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you have a lexer with formats containing multiple characters the reset position doesn't work as expected. Position is an internal pointer to the position of the lexer in the tokens array and not to the position as exposed in the token itself.
private function parseNamedReference(): string
{
$startPosition = $this->lexer->token['position'];
while ($this->lexer->moveNext()) {
}
�
$this->lexer->resetPosition($startPosition);
$this->lexer->moveNext();
$this->lexer->moveNext();
}
In the example above I would expect that a resetPosition would throw me back to the position on method entry. But since my tokens do have multiple characters, this doesn't work.
A fix would be to set the index of each token. Like this:
However, this would break the step process using $this->position++
another solution could be to have a map between the token position and location in the tokens array. This would have an impact on the memory usage since it would require an extra array of integers.
I would be happy to provide a patch to fix this issue, but I would like to have some guidance on what is expected in this library. Any change in resetPosition would be a breaking change as it would change the behavior of this lib.
The text was updated successfully, but these errors were encountered:
When you have a lexer with formats containing multiple characters the reset position doesn't work as expected. Position is an internal pointer to the position of the lexer in the
tokens
array and not to the position as exposed in the token itself.In the example above I would expect that a resetPosition would throw me back to the position on method entry. But since my tokens do have multiple characters, this doesn't work.
A fix would be to set the index of each token. Like this:
However, this would break the step process using
$this->position++
another solution could be to have a map between the token position and location in the
tokens
array. This would have an impact on the memory usage since it would require an extra array of integers.I would be happy to provide a patch to fix this issue, but I would like to have some guidance on what is expected in this library. Any change in
resetPosition
would be a breaking change as it would change the behavior of this lib.The text was updated successfully, but these errors were encountered: