aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2017-08-08 09:35:08 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2017-08-08 09:35:08 +0200
commit23cc8e191bdd9dd3aec73c7b450200ebccc0deb7 (patch)
tree25988ebee5d2814f6e96655e5d7f4aafef4d4f68
parent75a95809df5a5ce2e0922ea13699053c53c42780 (diff)
downloadCompiler-23cc8e191bdd9dd3aec73c7b450200ebccc0deb7.zip
Compiler-23cc8e191bdd9dd3aec73c7b450200ebccc0deb7.tar.gz
Compiler-23cc8e191bdd9dd3aec73c7b450200ebccc0deb7.tar.bz2
fix(llk/parser) Use current token if no error tok.
When the parser backtracks, an error token is not always found if it happens at the very first position. In this case, the parser uses the current token as a the error token.
-rw-r--r--Llk/Parser.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/Llk/Parser.php b/Llk/Parser.php
index ee3588c..e8a4dfe 100644
--- a/Llk/Parser.php
+++ b/Llk/Parser.php
@@ -187,12 +187,17 @@ class Parser
if (false === $this->backtrack()) {
$token = $this->_errorToken;
+
+ if (null === $this->_errorToken) {
+ $token = $this->_tokenSequence->current();
+ }
+
$offset = $token['offset'];
$line = 1;
$column = 1;
if (!empty($text)) {
- if (0 === $offset || null === $offset) {
+ if (0 === $offset) {
$leftnl = 0;
} else {
$leftnl = strrpos($text, "\n", -(strlen($text) - $offset) - 1) ?: 0;