[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator afa7cb9 050/434: Added unit tests for
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator afa7cb9 050/434: Added unit tests for retrieving grammar RHS |
Date: |
Mon, 29 Nov 2021 15:59:06 -0500 (EST) |
branch: externals/parser-generator
commit afa7cb9b05112f2defb44a87fea6be9f7bcac2f5
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Added unit tests for retrieving grammar RHS
---
parser.el | 12 ++++++------
test/parser-test.el | 27 +++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/parser.el b/parser.el
index a9a4315..f773a02 100644
--- a/parser.el
+++ b/parser.el
@@ -116,12 +116,12 @@
(dolist (p productions)
(let ((lhs (car p))
(rhs (cdr p)))
- (dolist (rhs-element rhs)
- (unless (listp rhs-element)
- (setq rhs-element (list rhs-element)))
- (let ((new-value (gethash lhs parser--table-productions)))
- (setq new-value (append new-value rhs))
- (puthash lhs new-value parser--table-productions)))))))
+ (let ((new-value (gethash lhs parser--table-productions)))
+ (dolist (rhs-element rhs)
+ (unless (listp rhs-element)
+ (setq rhs-element (list rhs-element)))
+ (push rhs-element new-value))
+ (puthash lhs (nreverse new-value) parser--table-productions))))))
(defun parser--set-look-ahead-number (k)
"Set look-ahead number K."
diff --git a/test/parser-test.el b/test/parser-test.el
index 24de34b..0b12126 100644
--- a/test/parser-test.el
+++ b/test/parser-test.el
@@ -337,15 +337,42 @@
(message "Passed tests for (parser--valid-production-p)"))
+(defun parser-test--get-grammar-rhs ()
+ "Test `parser--get-grammar-rhs'."
+ (message "Started tests for (parser--get-grammar-rhs)")
+
+ (parser--set-grammar '((S A) ("a" "b") ((S A) (A ("b" "a"))) S))
+ (should (equal
+ '((A))
+ (parser--get-grammar-rhs 'S)))
+ (should (equal
+ '(("b" "a"))
+ (parser--get-grammar-rhs 'A)))
+
+ (parser--set-grammar '((S A B) ("a" "b") ((S A) (S (B)) (B "a") (A "a") (A
("b" "a"))) S))
+ (should (equal
+ '((A) (B))
+ (parser--get-grammar-rhs 'S)))
+ (should (equal
+ '(("a") ("b" "a"))
+ (parser--get-grammar-rhs 'A)))
+
+ (message "Passed tests for (parser--get-grammar-rhs)"))
+
(defun parser-test ()
"Run test."
;; (setq debug-on-error t)
+
+ ;; Helpers
(parser-test--valid-look-ahead-number-p)
(parser-test--valid-production-p)
(parser-test--valid-grammar-p)
(parser-test--valid-sentential-form-p)
(parser-test--distinct)
(parser-test--sort-list)
+ (parser-test--get-grammar-rhs)
+
+ ;; Algorithms
(parser-test--first)
(parser-test--e-free-first)
(parser-test--follow)
- [elpa] externals/parser-generator bbbdea3 034/434: More improvement of documentation, (continued)
- [elpa] externals/parser-generator bbbdea3 034/434: More improvement of documentation, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 9d0d9e5 027/434: Various debugging, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator e644708 018/434: Improved validation of grammar syntax, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator fbb8cad 012/434: Starting a refactor, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 563cbdd 023/434: Passed FIRST tests for semi-complex grammar, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator dc78de7 025/434: Fixed page comment reference, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 3e02435 028/434: Passing complex 2 test, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 8e99d0c 035/434: Fixed typo, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator bc1ec12 036/434: Improved documentation, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator fe94691 048/434: Added hash-table for production RHS, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator afa7cb9 050/434: Added unit tests for retrieving grammar RHS,
ELPA Syncer <=
- [elpa] externals/parser-generator 603df44 040/434: Added failing unit tests for (parser--sort-list), ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator aadb31a 042/434: Updated README.md about FOLLOW-sets, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 586a38e 047/434: More work on algorithm 5.8, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 00ffcde 052/434: Added TODO items, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 7e051d3 054/434: Algorithm 5.8 completed but not tested, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 8e436df 056/434: More tweaking, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator a60952c 057/434: More debugging of new algorithm, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator ab0559d 060/434: More work, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator d7f43d7 066/434: Sorting lr-items for prefix before return, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator ca85ef4 068/434: Created TODO items, ELPA Syncer, 2021/11/29