mirror of https://github.com/vitalif/lime
Moved passing of errors to the parser itself
parent
acf176718d
commit
d88047272e
|
@ -359,6 +359,7 @@ class calc extends lime_parser {
|
||||||
"'%'" => 'modulo operator (%)',
|
"'%'" => 'modulo operator (%)',
|
||||||
"'^'" => 'exponentiation operator (^)'
|
"'^'" => 'exponentiation operator (^)'
|
||||||
);
|
);
|
||||||
|
public $errors = array();
|
||||||
function reduce_0_stmt_1($tokens, &$result) {
|
function reduce_0_stmt_1($tokens, &$result) {
|
||||||
// (0) stmt := exp
|
// (0) stmt := exp
|
||||||
$result = reset($tokens);
|
$result = reset($tokens);
|
||||||
|
@ -660,5 +661,5 @@ class calc extends lime_parser {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time: 0.12659001350403 seconds
|
// Time: 0.093108177185059 seconds
|
||||||
// Memory: 2765212 bytes
|
// Memory: 2768108 bytes
|
||||||
|
|
|
@ -61,6 +61,7 @@ class parser extends lime_parser {
|
||||||
public $d = array(
|
public $d = array(
|
||||||
|
|
||||||
);
|
);
|
||||||
|
public $errors = array();
|
||||||
function reduce_0_slist_1($tokens, &$result) {
|
function reduce_0_slist_1($tokens, &$result) {
|
||||||
// (0) slist := slist stmt ';'
|
// (0) slist := slist stmt ';'
|
||||||
$result = reset($tokens);
|
$result = reset($tokens);
|
||||||
|
@ -148,5 +149,5 @@ class parser extends lime_parser {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time: 0.039383888244629 seconds
|
// Time: 0.032855033874512 seconds
|
||||||
// Memory: 1514364 bytes
|
// Memory: 1516852 bytes
|
||||||
|
|
1
lime.php
1
lime.php
|
@ -1063,6 +1063,7 @@ class lime_language_php extends lime_language {
|
||||||
$code .= 'public $qi = ' . lime_export($ptab['qi'], true) . ';' . PHP_EOL;
|
$code .= 'public $qi = ' . lime_export($ptab['qi'], true) . ';' . PHP_EOL;
|
||||||
$code .= 'public $i = ' . lime_export($ptab['i'], true) . ';' . PHP_EOL;
|
$code .= 'public $i = ' . lime_export($ptab['i'], true) . ';' . PHP_EOL;
|
||||||
$code .= 'public $d = ' . lime_export($ptab['d'], true) . ';' . PHP_EOL;
|
$code .= 'public $d = ' . lime_export($ptab['d'], true) . ';' . PHP_EOL;
|
||||||
|
$code .= 'public $errors = array();' . PHP_EOL;
|
||||||
|
|
||||||
$rc = array();
|
$rc = array();
|
||||||
$method = array();
|
$method = array();
|
||||||
|
|
|
@ -109,7 +109,6 @@ class parse_engine {
|
||||||
public $rule;
|
public $rule;
|
||||||
public $step;
|
public $step;
|
||||||
public $descr;
|
public $descr;
|
||||||
public $errors = array();
|
|
||||||
/**
|
/**
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
|
@ -132,7 +131,7 @@ class parse_engine {
|
||||||
public function reset() {
|
public function reset() {
|
||||||
$this->accept = false;
|
$this->accept = false;
|
||||||
$this->stack = new parse_stack($this->qi);
|
$this->stack = new parse_stack($this->qi);
|
||||||
$this->errors = array();
|
$this->parser->errors = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function enter_error_tolerant_state() {
|
private function enter_error_tolerant_state() {
|
||||||
|
@ -333,7 +332,7 @@ class parse_engine {
|
||||||
// get these before doing anything
|
// get these before doing anything
|
||||||
$expected = $this->get_steps();
|
$expected = $this->get_steps();
|
||||||
|
|
||||||
$this->errors[] = $this->descr($type, $semantic) . ' not expected, expected {' . implode(', ', $expected) . '}';
|
$this->parser->errors[] = $this->descr($type, $semantic) . ' not expected, expected {' . implode(', ', $expected) . '}';
|
||||||
|
|
||||||
if ($this->debug) echo "Possibilities before error fixing: {" . implode(', ', $expected) . "}\n";
|
if ($this->debug) echo "Possibilities before error fixing: {" . implode(', ', $expected) . "}\n";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue