[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator c4c68b2 302/434: Added progress-indica
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator c4c68b2 302/434: Added progress-indicator to goto-table generation |
Date: |
Mon, 29 Nov 2021 16:00:03 -0500 (EST) |
branch: externals/parser-generator
commit c4c68b2dfd62f85bf6b4d240d0f82d3377c5c0c9
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Added progress-indicator to goto-table generation
---
parser-generator-lr.el | 134 +++++++++++++++++++++++++++++--------------------
1 file changed, 79 insertions(+), 55 deletions(-)
diff --git a/parser-generator-lr.el b/parser-generator-lr.el
index 732de8d..6837f8c 100644
--- a/parser-generator-lr.el
+++ b/parser-generator-lr.el
@@ -273,6 +273,8 @@
(parser-generator--debug
(message "(parser-generator-lr--generate-goto-tables)"))
(let ((lr-item-set-new-index 0)
+ (marked-count 0)
+ (total-count 1)
(goto-table)
(unmarked-lr-item-sets)
(marked-lr-item-sets
@@ -292,11 +294,12 @@
(setq
lr-item-set-new-index
(1+ lr-item-set-new-index))
- ;; Mark the initial set
- (puthash
- e-set
- lr-item-set-new-index
- marked-lr-item-sets))
+ (let ((e-set-hash-key (format "%s" e-set)))
+ ;; Mark the initial set
+ (puthash
+ e-set-hash-key
+ lr-item-set-new-index
+ marked-lr-item-sets)))
;; (2) If a set of items a in S is unmarked
;; (3) Repeat step (2) until all sets of items in S are marked.
@@ -306,9 +309,15 @@
(goto-table-table))
(while unmarked-lr-item-sets
- (setq popped-item (pop unmarked-lr-item-sets))
- (setq lr-item-set-index (car popped-item))
- (setq lr-items (car (cdr popped-item)))
+ (setq
+ popped-item
+ (pop unmarked-lr-item-sets))
+ (setq
+ lr-item-set-index
+ (car popped-item))
+ (setq
+ lr-items
+ (car (cdr popped-item)))
(parser-generator--debug
(message "lr-item-set-index: %s" lr-item-set-index)
(message "marked lr-items: %s" lr-items)
@@ -370,57 +379,64 @@
(let ((prefix-lr-items
(parser-generator-lr--items-for-goto
lr-items
- symbol))) ;; TODO Optimize this
+ symbol)))
;; If a' = GOTO(a, X) is nonempty
(when prefix-lr-items
+ (let ((prefix-lr-items-hash-key
+ (format
+ "%s"
+ prefix-lr-items)))
- (parser-generator--debug
- (message
- "GOTO(%s, %s) = %s"
- lr-items
- symbol
- prefix-lr-items))
-
- ;; and is not already in S
- (let ((goto
- (gethash
- prefix-lr-items
- marked-lr-item-sets)))
- (if goto
- (progn
- (parser-generator--debug
- (message
- "Set already exists in: %s set: %s"
- goto
- prefix-lr-items))
- (push
- `(,symbol ,goto)
- goto-table-table))
+ (parser-generator--debug
+ (message
+ "GOTO(%s, %s) = %s"
+ lr-items
+ symbol
+ prefix-lr-items))
+
+ ;; and is not already in S
+ (let ((goto
+ (gethash
+ prefix-lr-items-hash-key
+ marked-lr-item-sets)))
+ (if goto
+ (progn
+ (parser-generator--debug
+ (message
+ "Set already exists in: %s set: %s"
+ goto
+ prefix-lr-items))
+ (push
+ `(,symbol ,goto)
+ goto-table-table))
- (parser-generator--debug
- (message
- "Set is new: %s"
- prefix-lr-items))
-
- ;; Note that GOTO(a, X) will always be empty if all items
in a
- ;; have the dot at the right end of the production
-
- ;; then add a' to S as an unmarked set of items
- (push
- `(,symbol ,lr-item-set-new-index)
- goto-table-table)
- (push
- `(,lr-item-set-new-index ,prefix-lr-items)
- unmarked-lr-item-sets)
- ;; (2) Mark a
- (puthash
- prefix-lr-items
- lr-item-set-new-index
- marked-lr-item-sets)
- (setq
- lr-item-set-new-index
- (1+ lr-item-set-new-index))))))))
+ (parser-generator--debug
+ (message
+ "Set is new: %s"
+ prefix-lr-items))
+
+ ;; Note that GOTO(a, X) will always be empty if all
items in a
+ ;; have the dot at the right end of the production
+
+ ;; then add a' to S as an unmarked set of items
+ (push
+ `(,symbol ,lr-item-set-new-index)
+ goto-table-table)
+ (push
+ `(,lr-item-set-new-index ,prefix-lr-items)
+ unmarked-lr-item-sets)
+ (setq
+ total-count
+ (1+ total-count))
+ ;; (2) Mark a
+ (puthash
+ prefix-lr-items-hash-key
+ lr-item-set-new-index
+ marked-lr-item-sets)
+ (setq
+ lr-item-set-new-index
+ (1+ lr-item-set-new-index)))))))))
(setq
goto-table-table
@@ -435,7 +451,15 @@
`(
,lr-item-set-index
,goto-table-table)
- goto-table)))
+ goto-table)
+ (setq
+ marked-count
+ (1+ marked-count))
+ (message
+ "Progress: %s / %s = %d%%"
+ marked-count
+ total-count
+ (* 100 (/ (float marked-count) (float total-count))))))
(setq
goto-table
- [elpa] externals/parser-generator 03ca2e9 247/434: Look-ahead generation now supports EOF symbol, (continued)
- [elpa] externals/parser-generator 03ca2e9 247/434: Look-ahead generation now supports EOF symbol, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 3563720 266/434: Updated docs about lexical analysis, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 412fd2a 273/434: Passing generation of GOTO-table for LR(0) grammar, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator bc23604 274/434: Fixed look-ahead, first and e-free-first with k = 0, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 1879cb0 271/434: Merge branch 'master' of git.cvj.se:/home/git/emacs-parser-generator, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 16bb2d8 262/434: Added translation example LRk parser, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator d173c1e 281/434: More work on exporting parser as code function, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator bd887ff 277/434: LR(0) Parser passing translation test, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 852f969 283/434: Merge branch 'master' of git.cvj.se:/home/git/emacs-parser-generator, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 0d6d46d 294/434: Debugging incremental issue with exported translator, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator c4c68b2 302/434: Added progress-indicator to goto-table generation,
ELPA Syncer <=
- [elpa] externals/parser-generator 586789d 308/434: Added cache to first calculation, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 236a124 322/434: More work on resolving conflicts, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 04c360b 318/434: LR-items set validation now supports symbols with attributes, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator ea02245 325/434: Improved debug output, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator e56bcff 324/434: Improved output of productions and action-tables, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator fb29641 337/434: Passing old context-sensitive precedence example with new structure, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 928b31d 343/434: More work on infix calculator, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 6a4b353 344/434: More work on translations, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 85d1b49 345/434: Infix calculator translation passing some tests, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 08e9876 347/434: Fixed bug with associating a translation to multiple productions, ELPA Syncer, 2021/11/29