branch: externals/parser-generator commit 944819dff1918d627d9b2c4008c8fc347457758c Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
More debugging incremental parsing --- parser-generator-lr.el | 20 ++++++++++++++------ test/parser-generator-lr-test.el | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/parser-generator-lr.el b/parser-generator-lr.el index 4ad5cf1..91d0aab 100644 --- a/parser-generator-lr.el +++ b/parser-generator-lr.el @@ -533,10 +533,22 @@ (unless parser-generator-lr--goto-tables (error "Missing GOTO-tables for grammar!")) - (let ((accept)) + (let ((accept) + (pre-index 0)) (while (and (not accept)) + ;; Save history when index has changed + (when + (> + parser-generator-lex-analyzer--index + pre-index) + (push + `(,parser-generator-lex-analyzer--index ,pushdown-list ,output ,translation) + history) + (setq pre-index + parser-generator-lex-analyzer--index)) + ;; (1) The lookahead string u, consisting of the next k input symbols, is determined. (let ((look-ahead (parser-generator-lex-analyzer--peek-next-look-ahead)) (look-ahead-full)) @@ -700,11 +712,7 @@ (when next-index (push production-lhs pushdown-list) - (push next-index pushdown-list) - - (push - `(,parser-generator-lex-analyzer--index ,pushdown-list ,output ,translation) - history))))))))) + (push next-index pushdown-list))))))))) ((equal action-match '(accept)) ;; (d) If f(u) = accept, we halt and declare the string diff --git a/test/parser-generator-lr-test.el b/test/parser-generator-lr-test.el index 49581ac..3f31e40 100644 --- a/test/parser-generator-lr-test.el +++ b/test/parser-generator-lr-test.el @@ -347,6 +347,7 @@ (while (< (car (car history)) input-tape-index) (push (car history) history-list) (pop history)) + ;; (setq history (nreverse history)) (message "input-tape-index: %s" input-tape-index) (message "pushdown-list: %s" pushdown-list) (message "output: %s" output)