emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/parser-generator a586a0e 162/434: More work on incremen


From: ELPA Syncer
Subject: [elpa] externals/parser-generator a586a0e 162/434: More work on incremental parsing
Date: Mon, 29 Nov 2021 15:59:32 -0500 (EST)

branch: externals/parser-generator
commit a586a0eb5d3318267b605d90190d9feaf7512c11
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    More work on incremental parsing
---
 parser-generator-lr.el           | 22 +++++++++++-----------
 test/parser-generator-lr-test.el | 31 +++++++++++++++++++++----------
 2 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/parser-generator-lr.el b/parser-generator-lr.el
index fe29519..4ad5cf1 100644
--- a/parser-generator-lr.el
+++ b/parser-generator-lr.el
@@ -480,14 +480,14 @@
      pushdown-list
      output
      translation
-     pushdown-list-history)
-  "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with 
PUSHDOWN-LIST, OUTPUT, TRANSLATION and PUSHDOWN-LIST-HISTORY."
+     history)
+  "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with 
PUSHDOWN-LIST, OUTPUT, TRANSLATION and HISTORY."
   (let ((result (parser-generator-lr--parse
                  input-tape-index
                  pushdown-list
                  output
                  translation
-                 pushdown-list-history)))
+                 history)))
     (nth 0 result)))
 
 (defun parser-generator-lr-translate
@@ -496,14 +496,14 @@
      pushdown-list
      output
      translation
-     pushdown-list-history)
-  "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with 
PUSHDOWN-LIST, OUTPUT, TRANSLATION and PUSHDOWN-LIST-HISTORY."
+     history)
+  "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with 
PUSHDOWN-LIST, OUTPUT, TRANSLATION and HISTORY."
   (let ((result (parser-generator-lr--parse
                  input-tape-index
                  pushdown-list
                  output
                  translation
-                 pushdown-list-history)))
+                 history)))
     (nth 1 result)))
 
 ;; Algorithm 5.7, p. 375
@@ -514,8 +514,8 @@
                pushdown-list
                output
                translation
-               pushdown-list-history)
-  "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with 
PUSHDOWN-LIST, OUTPUT, TRANSLATION and PUSHDOWN-LIST-HISTORY."
+               history)
+  "Perform a LR-parse via lex-analyzer, optionally at INPUT-TAPE-INDEX with 
PUSHDOWN-LIST, OUTPUT, TRANSLATION and HISTORY."
   (unless input-tape-index
     (setq input-tape-index 0))
   (unless pushdown-list
@@ -703,8 +703,8 @@
                               (push next-index pushdown-list)
 
                               (push
-                               `(,parser-generator-lex-analyzer--index 
,pushdown-list)
-                               pushdown-list-history)))))))))
+                               `(,parser-generator-lex-analyzer--index 
,pushdown-list ,output ,translation)
+                               history)))))))))
 
                ((equal action-match '(accept))
                 ;;    (d) If f(u) = accept, we halt and declare the string
@@ -721,7 +721,7 @@
     (list
      (nreverse output)
      translation
-     (nreverse pushdown-list-history))))
+     (nreverse history))))
 
 (provide 'parser-generator-lr)
 
diff --git a/test/parser-generator-lr-test.el b/test/parser-generator-lr-test.el
index cc02538..49581ac 100644
--- a/test/parser-generator-lr-test.el
+++ b/test/parser-generator-lr-test.el
@@ -338,16 +338,27 @@
   (let ((history (nth 2 (parser-generator-lr--parse))))
     (message "History: %s" history)
 
-    (let ((input-tape-index (car (nth 2 history)))
-          (pushdown-list (car (cdr (nth 2 history)))))
-      ;; (let ((parser-generator-lr--parse
-      ;;        input-tape-index
-      ;;        pushdown-list
-      ;;        output-history
-      ;;        translation-history
-      ;;        pushdown-list-history))
-      (message "input-tape-index: %s" input-tape-index)
-      (message "pushdown-list: %s" pushdown-list)))
+    (let ((history-state 2))
+      (let ((input-tape-index (nth 0 (nth history-state history)))
+            (pushdown-list (nth 1 (nth history-state history)))
+            (output (nreverse (nth 2 (nth history-state history))))
+            (translation (nth 3 (nth history-state history)))
+            (history-list))
+        (while (< (car (car history)) input-tape-index)
+          (push (car history) history-list)
+          (pop history))
+        (message "input-tape-index: %s" input-tape-index)
+        (message "pushdown-list: %s" pushdown-list)
+        (message "output: %s" output)
+        (message "translation: %s" translation)
+        (message "history-list: %s" history-list)
+        (let ((parse (parser-generator-lr--parse
+                      input-tape-index
+                      pushdown-list
+                      output
+                      translation
+                      history-list)))
+          (message "parse: %s" parse)))))
 
   (message "Passed tests for (parser-generator-lr--parse)"))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]