[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator d435e50 122/434: Passing unit test for
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator d435e50 122/434: Passing unit test for LR-parse |
Date: |
Mon, 29 Nov 2021 15:59:23 -0500 (EST) |
branch: externals/parser-generator
commit d435e5069a66cfa20c011f5885773664291e504a
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passing unit test for LR-parse
---
parser-lr.el | 36 +++++++-----------------------------
1 file changed, 7 insertions(+), 29 deletions(-)
diff --git a/parser-lr.el b/parser-lr.el
index 7a0d2c4..96133cc 100644
--- a/parser-lr.el
+++ b/parser-lr.el
@@ -493,7 +493,7 @@
(let ((action-tables (parser-lr--generate-action-tables)))
(while (and
(not accept)
- (< input-tape-index input-tape-length))
+ (<= input-tape-index input-tape-length))
;; (1) The lookahead string u, consisting of the next k input symbols,
is determined.
(let ((look-ahead)
@@ -513,12 +513,9 @@
(setq look-ahead-length (1+ look-ahead-length)))
(setq look-ahead (nreverse look-ahead))
- (message "look-ahead: %s" look-ahead)
(let ((table-index (car pushdown-list)))
- (message "table-index: %s" table-index)
(let ((action-table (car (cdr (nth table-index action-tables)))))
- (message "action-table: %s" action-table)
(let ((action-match nil)
(action-table-length (length action-table))
@@ -531,11 +528,9 @@
(< action-index action-table-length))
(let ((action (nth action-index action-table)))
(let ((action-look-ahead (car action)))
- (message "action-look-ahead: %s" action-look-ahead)
(push action-look-ahead possible-look-aheads)
(when (equal action-look-ahead look-ahead)
- (setq action-match (cdr action))
- (message "action-match: %s" action-match))))
+ (setq action-match (cdr action)))))
(setq action-index (1+ action-index)))
(unless action-match
@@ -551,7 +546,7 @@
(cond
((equal action-match '(shift))
- ;; TODO (a) If f(u) = shift, then the next input symbol, say
a
+ ;; (a) If f(u) = shift, then the next input symbol, say a
;; is removed from the input and shifted onto the pushdown
list.
;; The goto function g of the table on top of the pushdown
list
;; is applied to a to determine the new table to be placed on
@@ -560,9 +555,7 @@
;; and declare error.
(let ((a (nth input-tape-index input-tape)))
- (message "a: %s" a)
(let ((goto-table (car (cdr (nth table-index
goto-tables)))))
- (message "goto-table: %s" goto-table)
(let ((goto-table-length (length goto-table))
(goto-index 0)
(searching-match t)
@@ -574,8 +567,6 @@
(let ((goto-item (nth goto-index goto-table)))
(let ((goto-item-look-ahead (car goto-item))
(goto-item-next-index (car (cdr goto-item))))
- (message "goto-item-look-ahead: %s"
goto-item-look-ahead)
- (message "goto-item-next-index: %s"
goto-item-next-index)
(when (equal goto-item-look-ahead a)
(setq next-index goto-item-next-index)
@@ -591,9 +582,7 @@
(push a pushdown-list)
(push next-index pushdown-list)
- (setq input-tape-index (1+ input-tape-index))
- (message "Performed shift, new pushdown-list: %s"
pushdown-list)
- (message "new-input-tape-index: %s"
input-tape-index)))))
+ (setq input-tape-index (1+ input-tape-index))))))
((equal (car action-match) 'reduce)
;; (b) If f(u) = reduce i and production i is A -> a,
@@ -609,22 +598,16 @@
(let ((production
(parser--get-grammar-production-by-number production-number)))
(let ((production-lhs (car production))
(production-rhs (car (cdr production))))
- (message "production: %s, lhs: %s rhs: %s" production
production-lhs production-rhs)
(unless (equal production-rhs (list
parser--e-identifier))
- (let ((pop-items (* 2 (length (cdr production))))
+ (let ((pop-items (* 2 (length production-rhs)))
(popped-items 0))
- (message "Should pop %s items" pop-items)
(while (< popped-items pop-items)
(pop pushdown-list)
(setq popped-items (1+ popped-items)))))
- (message "pushdown-list: %s" pushdown-list)
(push production-number output)
- (message "new-output: %s" output)
(let ((new-table-index (car pushdown-list)))
- (message "new-table-index: %s" new-table-index)
(let ((goto-table (car (cdr (nth new-table-index
goto-tables)))))
- (message "goto-table: %s" goto-table)
(let ((goto-table-length (length goto-table))
(goto-index 0)
(searching-match t)
@@ -636,8 +619,6 @@
(let ((goto-item (nth goto-index goto-table)))
(let ((goto-item-look-ahead (car goto-item))
(goto-item-next-index (car (cdr
goto-item))))
- (message "goto-item-look-ahead: %s"
goto-item-look-ahead)
- (message "goto-item-next-index: %s"
goto-item-next-index)
(when (equal goto-item-look-ahead
production-lhs)
(setq next-index goto-item-next-index)
@@ -647,8 +628,7 @@
(when next-index
(push production-lhs pushdown-list)
- (push next-index pushdown-list)
- (message "Performed reduction, new
pushdown-list: %s" pushdown-list)))))))))
+ (push next-index pushdown-list)))))))))
((equal action-match '(accept))
;; (d) If f(u) = accept, we halt and declare the string
@@ -657,9 +637,7 @@
(setq accept t))
- (t (error (format "Invalid action-match: %s!" action-match)))
-
- )))))))
+ (t (error (format "Invalid action-match: %s!"
action-match))))))))))
(nreverse output)))
(provide 'parser-lr)
- [elpa] externals/parser-generator b2fd896 136/434: Added support for indexed tokens, (continued)
- [elpa] externals/parser-generator b2fd896 136/434: Added support for indexed tokens, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 4746c64 137/434: Updated example for LR parse with indexed tokens, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 04a3ec5 141/434: Added separate file for syntax analysis, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 71e4eaa 145/434: Merge branch 'master' of git.cvj.se:/home/git/emacs-parser-generator, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 173fe94 152/434: Preparations for translation, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator be557ba 013/434: More work on refactor, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator fdbdff7 157/434: Added unit test for SDT in LR-parser, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 2d56ab0 160/434: Made separate functions for parse and translate in LR-parser, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 7cfdea2 165/434: Passing tests for incremental lexer, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator b072fdd 175/434: Passed test for trailing e-identifier in EFF function, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator d435e50 122/434: Passing unit test for LR-parse,
ELPA Syncer <=
- [elpa] externals/parser-generator a31da28 173/434: Updated Parser WIP items, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator aaec6fa 189/434: Work on e-free first tests, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 922033f 198/434: Various stuff, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator fe10d4a 196/434: Passed tests for first 3 and first 4 of complex grammar, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 4cba5aa 203/434: Made new TODO items, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator ef60d96 204/434: Added failing test for new function the generates grammar prefixes, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 76e30f1 210/434: Sorted lines in test file, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator e88abf0 117/434: More work on parser, added error-handling, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 8328ab3 130/434: Added unit test for failing LRk Grammar Parse, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator e89a740 138/434: Fixed bug with goto-table generation were tokens were strings, ELPA Syncer, 2021/11/29