[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator f2791c1 022/434: Passed unit test 3 in
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator f2791c1 022/434: Passed unit test 3 intermediate grammar |
Date: |
Mon, 29 Nov 2021 15:59:00 -0500 (EST) |
branch: externals/parser-generator
commit f2791c19f732d43796f3045dc46ac00fc0335eac
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passed unit test 3 intermediate grammar
---
parser.el | 9 ++++--
test/parser-test.el | 92 ++++++++++++++++-------------------------------------
2 files changed, 34 insertions(+), 67 deletions(-)
diff --git a/parser.el b/parser.el
index 2ac43be..053720b 100644
--- a/parser.el
+++ b/parser.el
@@ -506,7 +506,11 @@
(push symbol first)
(setq first-length (1+ first-length)))
((parser--valid-non-terminal-p symbol)
- (let ((symbol-f-set (sort (gethash symbol (gethash (1-
i-max) parser--f-sets)) 'string<)))
+ (parser--debug
+ (message "non-terminal symbol: %s" symbol))
+ (let ((symbol-f-set (gethash symbol (gethash (1- i-max)
parser--f-sets))))
+ (parser--debug
+ (message "symbol-f-set: %s" symbol-f-set))
(when (> (length symbol-f-set) 1)
;; Handle this scenario here were a non-terminal can
result in different FIRST sets
(let ((symbol-f-set-index 1)
@@ -516,7 +520,8 @@
(let ((alternative-first-length (+ first-length
(length symbol-f-set-element)))
(alternative-first (append first
symbol-f-set-element))
(alternative-tape-index (1+
input-tape-index)))
- (push `(,alternative-tape-index
,alternative-first-length ,alternative-first) stack))))))
+ (push `(,alternative-tape-index
,alternative-first-length ,alternative-first) stack)))
+ (setq symbol-f-set-index (1+
symbol-f-set-index)))))
(setq first-length (+ first-length (length (car
symbol-f-set))))
(setq first (append first (car symbol-f-set)))))))
(setq input-tape-index (1+ input-tape-index)))
diff --git a/test/parser-test.el b/test/parser-test.el
index 9916fea..1c7ef74 100644
--- a/test/parser-test.el
+++ b/test/parser-test.el
@@ -42,113 +42,75 @@
(parser--first 'S)))
(message "Passed first 2 with rudimentary grammar")
+ (parser--set-grammar '((S) ("a" b "c") ((S ("a" b "c"))) S) 3)
(should
(equal
- '("a" b "c")
- (parser--first
- 3
- 'S
- '((S "a" b "c")))))
+ '(("a" b "c"))
+ (parser--first 'S)))
(message "Passed first 3 with rudimentary grammar")
+ (parser--set-grammar '((S A) (b) ((S A) (A b)) S) 2)
(should
(equal
- '(b)
- (parser--first
- 1
- 'S
- '((S A)
- (A b)))))
+ '((b))
+ (parser--first 'S)))
(message "Passed first 1 with intermediate grammar")
+ (parser--set-grammar '((S A) ("a" "b") ((S A) (A ("b" "a"))) S) 2)
(should
(equal
- '("b" "a")
- (parser--first
- 2
- 'S
- '((S A)
- (A ("b" "a"))))))
+ '(("b" "a"))
+ (parser--first 'S)))
(message "Passed first 2 with intermediate grammar")
+ (parser--set-grammar '((S A) ("a" "b" "c" "d") ((S A) (A ("b" "a" "c" "d")))
S) 3)
(should
(equal
- '("b" "a" "c")
- (parser--first
- 3
- 'S
- '((S A)
- (A ("b" "a" "c" e))))))
+ '(("b" "a" "c"))
+ (parser--first 'S)))
(message "Passed first 3 with intermediate grammar")
+ (parser--set-grammar '((S A B) ("c" "d") ((S A) (A B) (B c d)) S) 1)
(should
(equal
- '(c d)
- (parser--first
- 1
- 'S
- '((S A)
- (A B)
- (B (c d))))))
+ '((c) (d))
+ (parser--first 'S)))
(message "Passed first 1 with semi-complex grammar")
+ (parser--set-grammar '((S A B) (a c d f) ((S A a) (A B) (B (c f) d)) S) 2)
(should
(equal
- '((c f) (da))
- (parser--first
- 2
- 'S
- '((S (A a))
- (A B)
- (B (c f) d)))))
+ '((c f) (d a))
+ (parser--first 'S)))
(message "Passed first 2 with semi-complex grammar")
+ (parser--set-grammar '((S A B) ("a" "c" "d" "m") ((S A) (A (B "a" "m")) (B
"c" "d")) S) 3)
(should
(equal
'(("c" "a" "m") ("d" "a" "m"))
- (parser--first
- 3
- 'S
- '((S A)
- (A (B "a" "m"))
- (B "c" "d")))))
+ (parser--first 'S)))
(message "Passed first 3 with semi-complex grammar")
+ (parser--set-grammar '((S A B C) (a b c) ((S A B) (A (B a) e) (B (C b) C) (C
c e)) S) 1)
(should
(equal
'((a) (b) (c) (e))
- (parser--first
- 1
- 'S
- '((S (A B))
- (A (B a) e)
- (B (C b) C)
- (C c e)))))
+ (parser--first 'S)))
(message "Passed first 1 with complex grammar")
;; Example 5.28 p 402
+ (parser--set-grammar '((S A B C) ("a" "b" "c") ((S A B) (A (B "a") e) (B (C
"b") C) (C "c" e)) S) 2)
(should
(equal
'(("a") ("a" "b") ("a" "c") ("b") ("b" "a") ("c") ("c" "a") ("c" "b") (e))
- (parser--first
- 2
- 'S
- '((S (AB))
- (A (B "a") e)
- (B (C "b") C)
- (C "c" e)))))
+ (parser--first 'S)))
(message "Passed first 2 with complex grammar")
+ (parser--set-grammar '((S A B C) ("a" "b" "c") ((S A B) (A (B "a") e) (B (C
"b") C) (C "c" e)) S) 3)
(should
(equal
- '(("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 (A B))
- (A (B "a") e)
- (B (C "b") C)
- (C "c" 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 'S)))
(message "Passed first 3 with complex grammar")
(message "Passed tests for (parser--first)"))
- [elpa] branch externals/parser-generator created (now 4a3a51d), ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator b93ab8c 001/434: My initial commit, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator b8faa17 002/434: FIRSTk and EFFk working, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator ee0a623 003/434: Added TRAVIS and LICENSE, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator f5bfa40 004/434: Fixed typo in README, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 58798c8 010/434: Starting on calculation of valid LK-sets for a valid grammar prefix, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator f9c8348 008/434: Updated Travis and Makefil rule name, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 5f65cfc 015/434: More refactoring, using lists instead of string as grammar data type, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator f2791c1 022/434: Passed unit test 3 intermediate grammar,
ELPA Syncer <=
- [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, 2021/11/29