[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator a516e3f 234/434: Started on new test f
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator a516e3f 234/434: Started on new test for LR(2) Parser |
Date: |
Mon, 29 Nov 2021 15:59:48 -0500 (EST) |
branch: externals/parser-generator
commit a516e3f5ff1a46afe4dba0d0ae21a1125ba84c81
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Started on new test for LR(2) Parser
---
parser-generator.el | 2 +-
test/parser-generator-lr-test.el | 43 +++++++++++++++++++++++++++++-----------
2 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/parser-generator.el b/parser-generator.el
index c6b2ff5..a834882 100644
--- a/parser-generator.el
+++ b/parser-generator.el
@@ -11,7 +11,7 @@
(defvar parser-generator--debug
- nil
+ t
"Whether to print debug messages or not.")
(defvar parser-generator--e-identifier
diff --git a/test/parser-generator-lr-test.el b/test/parser-generator-lr-test.el
index 5a00f04..e257b4d 100644
--- a/test/parser-generator-lr-test.el
+++ b/test/parser-generator-lr-test.el
@@ -404,26 +404,46 @@
"Test `parser-generator-lr-parse' with k = 2."
(message "Started tests for (parser-generator-lr-parse) k = 2")
- (parser-generator-set-grammar '((Sp S) ("a" "b") ((Sp S) (S (S "a" S "b"))
(S e)) Sp))
+ ;;
https://stackoverflow.com/questions/62075086/what-is-an-lr2-parser-how-does-it-differ-from-an-lr1-parser
+ ;; S → RS | R
+ ;; R → abT
+ ;; T → aT | c | ε
+
+ (parser-generator-set-grammar
+ '((Sp S R T) (a b c) ((Sp S) (S (R S) (R)) (R (a b T)) (T (a T) (c) (e)))
Sp))
(parser-generator-set-look-ahead-number 2)
(parser-generator-process-grammar)
(let ((lr-items (parser-generator-lr--generate-goto-tables)))
(parser-generator--debug
(message
- "all lr-items: %s"
- (parser-generator--hash-values-to-list lr-items t)))
+ "LR-items: %s"
+ (parser-generator--hash-values-to-list
+ lr-items
+ t)))
+ (parser-generator--debug
+ (message "GOTO-tables: %s"
+ (parser-generator--hash-to-list
+ parser-generator-lr--goto-tables
+ t)))
(should
(equal
- '((0 (((S) 1)))
- (1 (((a) 2)))
- (2 (((S) 3)))
- (3 (((a) 4) ((b) 5)))
- (4 (((S) 6)))
+ '((0 ((R 2) (S 1) (a 3)))
+ (1 nil)
+ (2 ((R 10) (S 9) (a 11)))
+ (3 ((b 4)))
+ (4 ((T 5) (a 6) (c 7)))
(5 nil)
- (6 (((a) 4) ((b) 7)))
- (7 nil))
+ (6 ((T 8) (a 6) (c 7)))
+ (7 nil)
+ (8 nil)
+ (9 nil)
+ (10 ((R 10) (S 14) (a 11)))
+ (11 ((b 12)))
+ (12 ((T 13) (a 6) (c 7)))
+ (13 nil)
+ (14 nil))
(parser-generator--hash-to-list
parser-generator-lr--goto-tables)))
(message "Passed GOTO-tables k = 2")
@@ -673,8 +693,7 @@
(parser-generator-lr-test--generate-action-tables)
(parser-generator-lr-test-parse)
(parser-generator-lr-test-translate)
- ;;(parser-generator-lr-test-parse-k-2)
- )
+ (parser-generator-lr-test-parse-k-2))
(provide 'parser-generator-lr-test)
- [elpa] externals/parser-generator 18d7c63 195/434: Added new function to merge lists of terminals, (continued)
- [elpa] externals/parser-generator 18d7c63 195/434: Added new function to merge lists of terminals, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 60d9968 202/434: Fixed valid look-ahead with k above 1, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 38223d3 206/434: Passed tests for generating grammar prefixes, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 8a6b752 208/434: Starting on adding support for LR k > 1 parser, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator d604092 223/434: Added failing unit test for e-free-first function, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 172d530 214/434: Improved handling of production LHS to enable multiple symbols, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator fbc8f8b 225/434: Removed dependency of hash-table of terminals for LR parser, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 870eca2 232/434: Reduced depth of GOTO-table to always use one symbol, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 5b45b2b 235/434: Improved comments, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator c2d2d0d 239/434: Fixed FIRST calculating when building lr-item sets, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator a516e3f 234/434: Started on new test for LR(2) Parser,
ELPA Syncer <=
- [elpa] externals/parser-generator 06c09bc 254/434: Removed commented-out code, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator a796d8d 253/434: Added another passing unit test for k=2, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator b2193b2 251/434: GOTO-items now only contain one symbol in parse function, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator d147355 256/434: Fixed a bug in processing production RHS when loading symbols, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 8e3084b 270/434: More work LRk parser k = 0, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 58190dc 272/434: LR Parser k=0 building correct LR items, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 0f8aa1d 265/434: Updated LRk README, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator f0cd9f6 280/434: Started on test for export parser feature, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 3e9b4ee 279/434: Improved README, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 2920af5 286/434: Parser is exported but helper-functions are missing still, ELPA Syncer, 2021/11/29