[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator 7bc3b70 017/434: Updated tests to use
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator 7bc3b70 017/434: Updated tests to use new data structure |
Date: |
Mon, 29 Nov 2021 15:58:59 -0500 (EST) |
branch: externals/parser-generator
commit 7bc3b7063c4fe78aedd296bfa6f8a6f076041c71
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Updated tests to use new data structure
---
parser.el | 20 +++++++++-
test/parser-test.el | 108 +++++++++++++++++++++++-----------------------------
2 files changed, 67 insertions(+), 61 deletions(-)
diff --git a/parser.el b/parser.el
index f834667..e959931 100644
--- a/parser.el
+++ b/parser.el
@@ -165,7 +165,25 @@
(setq terminal-index (1+ terminal-index)))))
;; TODO Check every production
- ;; TODO Check start
+ (let ((productions (nth 2 G)))
+ (let ((production-count (length productions))
+ (production-index 0))
+ (while (and
+ valid-p
+ (< production-index production-count))
+ (let ((production (nth production-index productions)))
+ (unless (or
+ (symbolp production)
+ (stringp production))
+ (setq valid-p nil)))
+ (setq production-index (1+ production-index)))))
+
+ ;; Check start
+ (let ((start (nth 3 G)))
+ (when (and
+ valid-p
+ (not (or (stringp start) (symbolp start))))
+ (setq valid-p nil)))
)
valid-p))
diff --git a/test/parser-test.el b/test/parser-test.el
index b7686da..615c0ea 100644
--- a/test/parser-test.el
+++ b/test/parser-test.el
@@ -30,162 +30,150 @@
(should
(equal
- '("a")
+ '(a)
(parser--first
1
'S
- '(
- (S a)))))
+ '((S a)))))
(message "Passed first 1 with rudimentary grammar")
(should
(equal
- '("ab")
+ '("a" "b")
(parser--first
2
'S
'(
- (S abc)))))
+ (S "a" "b" "c")))))
(message "Passed first 2 with rudimentary grammar")
(should
(equal
- '("abc")
+ '("a" b "c")
(parser--first
3
'S
- '(
- (S abc)))))
+ '((S "a" b "c")))))
(message "Passed first 3 with rudimentary grammar")
(should
(equal
- '("b")
+ '(b)
(parser--first
1
'S
- '(
- (S A)
+ '((S A)
(A b)))))
(message "Passed first 1 with intermediate grammar")
(should
(equal
- '("ba")
+ '("b" "a")
(parser--first
2
'S
- '(
- (S A)
- (A ba)))))
+ '((S A)
+ (A ("b" "a"))))))
(message "Passed first 2 with intermediate grammar")
(should
(equal
- '("bac")
+ '("b" "a" "c")
(parser--first
3
'S
- '(
- (S A)
- (A bace)))))
+ '((S A)
+ (A ("b" "a" "c" e))))))
(message "Passed first 3 with intermediate grammar")
(should
(equal
- '("c" "d")
+ '(c d)
(parser--first
1
'S
- '(
- (S A)
+ '((S A)
(A B)
- (B c d)))))
+ (B (c d))))))
(message "Passed first 1 with semi-complex grammar")
(should
(equal
- '("cf" "da")
+ '((c f) (da))
(parser--first
2
'S
- '(
- (S Aa)
+ '((S (A a))
(A B)
- (B cf d)))))
+ (B (c f) d)))))
(message "Passed first 2 with semi-complex grammar")
(should
(equal
- '("cam" "dam")
+ '(("c" "a" "m") ("d" "a" "m"))
(parser--first
3
'S
- '(
- (S A)
- (A Bam)
- (B c d)))))
+ '((S A)
+ (A (B "a" "m"))
+ (B "c" "d")))))
(message "Passed first 3 with semi-complex grammar")
(should
(equal
- '("a" "b" "c" "e")
+ '((a) (b) (c) (e))
(parser--first
1
'S
- '(
- (S AB)
- (A Ba e)
- (B Cb C)
+ '((S (A B))
+ (A (B a) e)
+ (B (C b) C)
(C c e)))))
(message "Passed first 1 with complex grammar")
;; Example 5.28 p 402
(should
(equal
- '("a" "ab" "ac" "b" "ba" "c" "ca" "cb" "e")
+ '(("a") ("a" "b") ("a" "c") ("b") ("b" "a") ("c") ("c" "a") ("c" "b") (e))
(parser--first
2
'S
- '(
- (S AB)
- (A Ba e)
- (B Cb C)
- (C c e)))))
+ '((S (AB))
+ (A (B "a") e)
+ (B (C "b") C)
+ (C "c" e)))))
(message "Passed first 2 with complex grammar")
(should
(equal
- '("a" "ab" "ac" "acb" "b" "ba" "bab" "bac" "c" "ca" "cab" "cac" "cb" "cba"
"e")
+ '(("a") ("a" "b") ("a" "c") ("a" "c" "b") "b" ("b" "a") ("b" "a" "b") ("b"
"a" "c") "c" ("c" "a") ("c" "a" "b") ("c" "a" "c") ("c" "b") ("c" "b" "a") e)
(parser--first
3
'S
- '(
- (S AB)
- (A Ba e)
- (B Cb C)
- (C c e)))))
+ '((S (A B))
+ (A (B "a") e)
+ (B (C "b") C)
+ (C "c" e)))))
(message "Passed first 3 with complex grammar")
(message "Passed tests for (parser--first)"))
;; Example 5.28 page 402
-(defun parser-test--empty-free-first ()
- "Test `parser--empty-free-first'."
- (message "Starting tests for (parser--empty-free-first)")
+(defun parser-test--e-free-first ()
+ "Test `parser--e-free-first'."
+ (message "Starting tests for (parser--e-free-first)")
;; Example 5.28 p 402
(should
(equal
- '("ca" "cb")
- (parser--empty-free-first
+ '(("c" "a") ("c" "b"))
+ (parser--e-free-first
2
'S
- '(
- (S AB)
- (A Ba e)
- (B Cb C)
- (C c e)))))
+ '((S (A B))
+ (A (B "a") e)
+ (B (C "b") C)
+ (C "c" e)))))
(message "Passed empty-free-first 2 with complex grammar")
(message "Passed tests for (parser--empty-free-first)"))
@@ -283,7 +271,7 @@
(parser-test--distinct)
(parser-test--valid-sentential-form-p)
(parser-test--first)
- (parser-test--empty-free-first)
+ (parser-test--e-free-first)
;; (parser-test--v-set)
)
- [elpa] externals/parser-generator f2791c1 022/434: Passed unit test 3 intermediate grammar, (continued)
- [elpa] externals/parser-generator f2791c1 022/434: Passed unit test 3 intermediate grammar, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 5d9b98c 011/434: Added functions to validate G and k and tests, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 356720c 030/434: Passing all unit tests using new data structure, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator e4fd795 007/434: Added compilation to test, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 42d92f1 014/434: More refactoring, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator f648b52 020/434: Passing first unit test for FIRST after new data-structure refactor, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator a4bbb2f 026/434: Using PDA algorithm for FIRST when β is above 1 symbol, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator e02d5d7 049/434: More work on calculating valid LR-items, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 0465b58 045/434: Improved commenting, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 85dde51 009/434: Added License and Travis build logos, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 7bc3b70 017/434: Updated tests to use new data structure,
ELPA Syncer <=
- [elpa] externals/parser-generator ab4b4db 021/434: Passed second FIRST test again, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 80cf73d 019/434: Passing tests for valid-grammar syntax, ELPA Syncer, 2021/11/29
- [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