[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator 1b8f025 016/434: More work on validati
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator 1b8f025 016/434: More work on validating a grammar structure |
Date: |
Mon, 29 Nov 2021 15:58:59 -0500 (EST) |
branch: externals/parser-generator
commit 1b8f02569b077b56a0a18a8cf518c28bd1dd7092
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More work on validating a grammar structure
---
parser.el | 33 +++++++++++++++++++++++++++++++++
test/parser-test.el | 7 +++++++
2 files changed, 40 insertions(+)
diff --git a/parser.el b/parser.el
index ca57f8f..f834667 100644
--- a/parser.el
+++ b/parser.el
@@ -134,6 +134,39 @@
(stringp (nth 3 G))
(symbolp (nth 3 G))))))
(setq valid-p nil))
+ (when valid-p
+
+ ;; Check every non-terminal
+ (let ((non-terminals (nth 0 G)))
+ (let ((non-terminal-count (length non-terminals))
+ (non-terminal-index 0))
+ (while (and
+ valid-p
+ (< non-terminal-index non-terminal-count))
+ (let ((non-terminal (nth non-terminal-index non-terminals)))
+ (unless (or
+ (symbolp non-terminal)
+ (stringp non-terminal))
+ (setq valid-p nil)))
+ (setq non-terminal-index (1+ non-terminal-index)))))
+
+ ;; Check every terminal
+ (let ((terminals (nth 1 G)))
+ (let ((terminal-count (length terminals))
+ (terminal-index 0))
+ (while (and
+ valid-p
+ (< terminal-index terminal-count))
+ (let ((terminal (nth terminal-index terminals)))
+ (unless (or
+ (symbolp terminal)
+ (stringp terminal))
+ (setq valid-p nil)))
+ (setq terminal-index (1+ terminal-index)))))
+
+ ;; TODO Check every production
+ ;; TODO Check start
+ )
valid-p))
(defun parser--valid-look-ahead-number-p (k)
diff --git a/test/parser-test.el b/test/parser-test.el
index d12a4e5..b7686da 100644
--- a/test/parser-test.el
+++ b/test/parser-test.el
@@ -270,11 +270,18 @@
(message "Passed tests for (parser--valid-look-ahead-number-p)"))
+(defun parser-test--valid-sentential-form-p ()
+ "Test `parser--valid-sentential-form-p'."
+ (message "Starting tests for (parser--valid-sentential-form-p)")
+
+ (message "Passed tests for (parser--valid-sentential-form-p)"))
+
(defun parser-test ()
"Run test."
(parser-test--valid-look-ahead-number-p)
(parser-test--valid-grammar-p)
(parser-test--distinct)
+ (parser-test--valid-sentential-form-p)
(parser-test--first)
(parser-test--empty-free-first)
;; (parser-test--v-set)
- [elpa] externals/parser-generator 06d23f5 340/434: More debugging, (continued)
- [elpa] externals/parser-generator 06d23f5 340/434: More debugging, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator f213255 348/434: Passed all old unit tests again after translation refactor, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 886af5c 349/434: Uncommented export tests until refactor is ok, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 99aa5b6 350/434: Added more unit tests for calculator, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator d8fb2da 354/434: Just white-space fixes, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 3964649 359/434: Added more failing unit tests, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 6e0e781 360/434: More debugging, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 2c262a4 362/434: Added new error when there is grammar conflict in action-table generation and no precedence comparison function is defined, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator a7a9506 366/434: Refactored structure of context-sensitive attributes, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 98ab0e4 377/434: More work on precedence logic in unit tests, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 1b8f025 016/434: More work on validating a grammar structure,
ELPA Syncer <=
- [elpa] externals/parser-generator 1ae36fc 029/434: Added support for calculating first of a sentential form, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 38c2040 032/434: Improved markdown code examples, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator e463bae 041/434: Passing tests for sorting lists, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 840c418 044/434: Improved comment about follow function, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 2a3a02d 083/434: Removed cache for LR-items for prefixes, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 3ba5250 090/434: Removed debugging stuff, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 83298fe 099/434: Passing test for function that generates possible look-ahead permutations, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator e9697ea 100/434: Added function that tests if a look-ahead is valid or not, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 53c09f7 119/434: Added hash-table for productions indexed by production-number, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 58e5806 129/434: Renamed plugin from parser to parser-generator, ELPA Syncer, 2021/11/29