Fixing line error reporting for some edge cases

This commit is contained in:
Pavel Shevaev 2023-05-17 23:47:45 +03:00
parent f9e38c9cd7
commit 11d26bdb94
1 changed files with 7 additions and 3 deletions

View File

@ -594,11 +594,15 @@ class mtgMetaInfoParser
private function _validatePropToken($name, $value)
{
if(!isset($this->config['valid_tokens']) || !$this->config['valid_tokens'])
if(!isset($this->config['valid_tokens']) ||
!is_array($this->config['valid_tokens']))
return;
if(!in_array($name, $this->config['valid_tokens']))
{
--$this->line; //hack for more precise reporting
throw new Exception("Unknown token '$name'");
}
}
private function _symbol()
@ -779,7 +783,7 @@ class mtgMetaInfoParser
$t = ord($t);
if($t !== $this->token)
{
$this->_error("Expecting '" . $this->_toStr($t) . "' instead got '" . $this->_toStr($this->token) . "'");
$this->_error("expecting '" . $this->_toStr($t) . "' instead got '" . $this->_toStr($this->token) . "'");
}
$attr = $this->attribute;
@ -796,7 +800,7 @@ class mtgMetaInfoParser
private function _error($msg)
{
throw new Exception($msg . "(token: {$this->token}, attr: {$this->attribute}})");
throw new Exception($msg . "(token: {$this->token}, attr: {$this->attribute})");
}
}