diff --git a/examples/calc/calc.class b/examples/calc/calc.class index e0001d7..d933a31 100644 --- a/examples/calc/calc.class +++ b/examples/calc/calc.class @@ -359,6 +359,7 @@ class calc extends lime_parser { "'%'" => 'modulo operator (%)', "'^'" => 'exponentiation operator (^)' ); + public $errors = array(); function reduce_0_stmt_1($tokens, &$result) { // (0) stmt := exp $result = reset($tokens); @@ -660,5 +661,5 @@ class calc extends lime_parser { ); } -// Time: 0.12659001350403 seconds -// Memory: 2765212 bytes +// Time: 0.093108177185059 seconds +// Memory: 2768108 bytes diff --git a/examples/error/error.class b/examples/error/error.class index 8e1dc06..286dc89 100644 --- a/examples/error/error.class +++ b/examples/error/error.class @@ -61,6 +61,7 @@ class parser extends lime_parser { public $d = array( ); + public $errors = array(); function reduce_0_slist_1($tokens, &$result) { // (0) slist := slist stmt ';' $result = reset($tokens); @@ -148,5 +149,5 @@ class parser extends lime_parser { ); } -// Time: 0.039383888244629 seconds -// Memory: 1514364 bytes +// Time: 0.032855033874512 seconds +// Memory: 1516852 bytes diff --git a/lime.php b/lime.php index 6aa7896..c323d6f 100755 --- a/lime.php +++ b/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 $i = ' . lime_export($ptab['i'], true) . ';' . PHP_EOL; $code .= 'public $d = ' . lime_export($ptab['d'], true) . ';' . PHP_EOL; + $code .= 'public $errors = array();' . PHP_EOL; $rc = array(); $method = array(); diff --git a/parse_engine.php b/parse_engine.php index ceadea3..3d67970 100644 --- a/parse_engine.php +++ b/parse_engine.php @@ -109,7 +109,6 @@ class parse_engine { public $rule; public $step; public $descr; - public $errors = array(); /** * @var boolean */ @@ -132,7 +131,7 @@ class parse_engine { public function reset() { $this->accept = false; $this->stack = new parse_stack($this->qi); - $this->errors = array(); + $this->parser->errors = array(); } private function enter_error_tolerant_state() { @@ -333,7 +332,7 @@ class parse_engine { // get these before doing anything $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";