[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator 83298fe 099/434: Passing test for func
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator 83298fe 099/434: Passing test for function that generates possible look-ahead permutations |
Date: |
Mon, 29 Nov 2021 15:59:17 -0500 (EST) |
branch: externals/parser-generator
commit 83298fe6a9cb3feaadbea395ddfd67f07e2e877f
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passing test for function that generates possible look-ahead permutations
---
parser.el | 31 +++++++------------------------
test/parser-test.el | 4 ++--
2 files changed, 9 insertions(+), 26 deletions(-)
diff --git a/parser.el b/parser.el
index dc962f6..35c8362 100644
--- a/parser.el
+++ b/parser.el
@@ -118,42 +118,27 @@
(look-ahead-length)
(look-ahead))
(while stack
- (message "stack 1: %s" stack)
(let ((item (pop stack)))
(setq terminal-index (nth 0 item))
(setq look-ahead-length (nth 1 item))
(setq look-ahead (nth 2 item))
- (message "Popped")
- (message "item: %s" item)
- (message "look-ahead-length: %s" look-ahead-length)
- (message "look-ahead: %s" look-ahead)
-
(while (and
(< look-ahead-length k)
(<= terminal-index terminals-max-index))
- (message "stack 2: %s" stack)
(let ((potential-look-ahead look-ahead)
(next-terminal (nth terminal-index terminals)))
(push next-terminal potential-look-ahead)
- (unless (gethash (format "%s" potential-look-ahead) marked-paths)
- (message "potential-look-ahead: %s gethash: %s"
potential-look-ahead (gethash potential-look-ahead marked-paths))
- (puthash (format "%s" potential-look-ahead) t marked-paths)
+ (if (gethash potential-look-ahead marked-paths)
+ (setq terminal-index (1+ terminal-index))
+ (puthash potential-look-ahead t marked-paths)
- (let ((stack-item (list terminal-index look-ahead-length
look-ahead)))
- (push stack-item stack)
- (message "Added old path to stack: %s %s" stack-item stack))
+ (push `(,terminal-index ,look-ahead-length,look-ahead) stack)
(setq look-ahead-length (1+ look-ahead-length))
(setq look-ahead potential-look-ahead)
+ (setq terminal-index 0))))
- (message "Added-terminal: %s" next-terminal)
- (message "look-ahead-length: %s" look-ahead-length)
- (message "look-ahead: %s" look-ahead)
- (message "Stack 3: %s" stack)))
- (setq terminal-index (1+ terminal-index)))
-
- (message "Stack 5: %s" stack)
(let ((look-ahead-to-add))
(if look-ahead
(progn
@@ -164,7 +149,7 @@
(when (and
include-e
(= look-ahead-length (1- k)))
- (push parser--e-identifier look-aheads)
+ (push parser--e-identifier look-ahead)
(setq look-ahead-to-add (reverse look-ahead))))
(when (and
@@ -172,12 +157,10 @@
(= k 1))
(setq look-ahead-to-add `(,parser--e-identifier))))
- (message "look-ahead-to-add: %s" look-ahead-to-add)
(when (and look-ahead-to-add
(not (gethash look-ahead-to-add added-look-aheads)))
(puthash look-ahead-to-add t added-look-aheads)
- (push look-ahead-to-add look-aheads))))
- (message "Stack 4: %s" stack)))
+ (push look-ahead-to-add look-aheads))))))
(sort look-aheads 'parser--sort-list)))
diff --git a/test/parser-test.el b/test/parser-test.el
index ef4d41c..fa76cc1 100644
--- a/test/parser-test.el
+++ b/test/parser-test.el
@@ -32,13 +32,13 @@
(should
(equal
- '((a a) (a b) (b a) (b b))
+ '(("a" "a") ("a" "b") ("b" "a") ("b" "b"))
(parser--get-possible-look-aheads)))
(message "Passed ((a a) (a b) (b a) (b b))")
(should
(equal
- '((a a) (a b) (a e) (b a) (b b) (b e))
+ '(("a" "a") ("a" "b") ("a" e) ("b" "a") ("b" "b") ("b" e))
(parser--get-possible-look-aheads t)))
(message "Passed tests for (parser--get-possible-look-aheads)"))
- [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, (continued)
- [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, 2021/11/29
- [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 <=
- [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
- [elpa] externals/parser-generator 0695275 143/434: More updates to docs, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 1b17ef8 159/434: Added another unit tests for translations, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 04fdc96 167/434: Added unit-test for incremental translations, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator fa6237a 170/434: Added TODO items, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 71f03cc 171/434: Updated example, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 0b72792 177/434: Added failing unit tests for FIRST, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 181b499 178/434: Fixed bug in FIRST generation where multiple equal LHS:s, ELPA Syncer, 2021/11/29