[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator 08e9876 347/434: Fixed bug with associ
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator 08e9876 347/434: Fixed bug with associating a translation to multiple productions |
Date: |
Mon, 29 Nov 2021 16:00:12 -0500 (EST) |
branch: externals/parser-generator
commit 08e98765e65ee170d3119dc6f2db262f0f9e8778
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Fixed bug with associating a translation to multiple productions
---
parser-generator-lr.el | 70 ++++++++++----------
parser-generator.el | 174 ++++++++++++++++++++++++-------------------------
2 files changed, 122 insertions(+), 122 deletions(-)
diff --git a/parser-generator-lr.el b/parser-generator-lr.el
index 8934b3f..6820b99 100644
--- a/parser-generator-lr.el
+++ b/parser-generator-lr.el
@@ -1870,54 +1870,54 @@
popped-items-meta-contents)))
(parser-generator--debug
(message
- "translation-symbol-table: %s = %s"
+ "translation-symbol-table: %S = %S
(processed)"
production-lhs
partial-translation))
+ (let ((temp-hash-key
+ (format
+ "%S"
+ production-lhs)))
+ (let ((symbol-translations
+ (gethash
+ temp-hash-key
+ translation-symbol-table)))
+ (push
+ partial-translation
+ symbol-translations)
+ (puthash
+ temp-hash-key
+ (reverse symbol-translations)
+ translation-symbol-table)
+ (setq
+ translation
+ partial-translation))))
+
+ ;; When no translation is specified just use
popped contents as translation
+ (let ((partial-translation
+ popped-items-meta-contents))
+ (parser-generator--debug
+ (message
+ "translation-symbol-table: %S = %S (generic)"
+ production-lhs
+ partial-translation))
+ (let ((temp-hash-key
+ (format
+ "%S"
+ production-lhs)))
(let ((symbol-translations
(gethash
- (format
- "%S"
- production-lhs)
+ temp-hash-key
translation-symbol-table)))
(push
partial-translation
symbol-translations)
(puthash
- (format
- "%S"
- production-lhs)
+ temp-hash-key
(reverse symbol-translations)
translation-symbol-table)
(setq
translation
- partial-translation)))
-
- ;; When no translation is specified just use
popped contents as translation
- (let ((partial-translation
- popped-items-meta-contents))
- (parser-generator--debug
- (message
- "translation-symbol-table: %s = %s (generic)"
- production-lhs
- partial-translation))
- (let ((symbol-translations
- (gethash
- (format
- "%S"
- production-lhs)
- translation-symbol-table)))
- (push
- partial-translation
- symbol-translations)
- (puthash
- (format
- "%S"
- production-lhs)
- (reverse symbol-translations)
- translation-symbol-table)
- (setq
- translation
- partial-translation)))))
+ partial-translation))))))
(let ((new-table-index (car pushdown-list)))
(let ((goto-table-distinct-index
diff --git a/parser-generator.el b/parser-generator.el
index b3520c8..befa2ca 100644
--- a/parser-generator.el
+++ b/parser-generator.el
@@ -17,7 +17,7 @@
(defvar
parser-generator--debug
- nil
+ t
"Whether to print debug messages or not.")
(defvar
@@ -473,8 +473,7 @@
(dolist (p productions)
(let ((lhs (car p))
(rhs (cdr p))
- (production)
- (translation))
+ (production))
(unless (listp lhs)
(setq lhs (list lhs)))
(let ((new-value
@@ -488,98 +487,99 @@
(<
rhs-element-index
rhs-length)
- (setq
- rhs-element
- (nth
- rhs-element-index
- rhs))
- (when (functionp rhs-element)
- (error
- "Unexpected function element %s in RHS %s of LHS %s"
+ (let ((translation))
+ (setq
rhs-element
- rhs
- lhs))
- (unless (listp rhs-element)
- (setq rhs-element (list rhs-element)))
- (let ((sub-rhs-element-index 0)
- (sub-rhs-element-length (length rhs-element))
- (sub-rhs-element)
- (new-rhs))
- (while
- (<
- sub-rhs-element-index
- sub-rhs-element-length)
- (setq
- sub-rhs-element
- (nth
- sub-rhs-element-index
- rhs-element))
- (if (and
- (listp sub-rhs-element)
- (functionp sub-rhs-element))
- (setq
- translation
- sub-rhs-element)
- (unless
- (or
- (parser-generator--valid-terminal-p sub-rhs-element)
- (parser-generator--valid-non-terminal-p
sub-rhs-element)
- (parser-generator--valid-e-p sub-rhs-element)
- (parser-generator--valid-eof-p sub-rhs-element))
- (error
- "Element %s in RHS %s of production %s is not a valid
terminal, non-terminal, e-identifier or EOF-identifier!"
- sub-rhs-element
- rhs-element
- lhs))
- (push
+ (nth
+ rhs-element-index
+ rhs))
+ (when (functionp rhs-element)
+ (error
+ "Unexpected function element %s in RHS %s of LHS %s"
+ rhs-element
+ rhs
+ lhs))
+ (unless (listp rhs-element)
+ (setq rhs-element (list rhs-element)))
+ (let ((sub-rhs-element-index 0)
+ (sub-rhs-element-length (length rhs-element))
+ (sub-rhs-element)
+ (new-rhs))
+ (while
+ (<
+ sub-rhs-element-index
+ sub-rhs-element-length)
+ (setq
sub-rhs-element
- new-rhs))
+ (nth
+ sub-rhs-element-index
+ rhs-element))
+ (if (and
+ (listp sub-rhs-element)
+ (functionp sub-rhs-element))
+ (setq
+ translation
+ sub-rhs-element)
+ (unless
+ (or
+ (parser-generator--valid-terminal-p sub-rhs-element)
+ (parser-generator--valid-non-terminal-p
sub-rhs-element)
+ (parser-generator--valid-e-p sub-rhs-element)
+ (parser-generator--valid-eof-p sub-rhs-element))
+ (error
+ "Element %s in RHS %s of production %s is not a valid
terminal, non-terminal, e-identifier or EOF-identifier!"
+ sub-rhs-element
+ rhs-element
+ lhs))
+ (push
+ sub-rhs-element
+ new-rhs))
+ (setq
+ sub-rhs-element-index
+ (1+ sub-rhs-element-index)))
(setq
- sub-rhs-element-index
- (1+ sub-rhs-element-index)))
+ production
+ (list
+ lhs
+ (reverse new-rhs)))
+ (message
+ "Production %s: %S"
+ production-index
+ production)
+ (push
+ (reverse new-rhs)
+ new-value)
+ (puthash
+ lhs
+ (reverse new-value)
+ parser-generator--table-productions-rhs))
(setq
+ rhs-element-index
+ (1+ rhs-element-index))
+ (puthash
production
- (list
- lhs
- (reverse new-rhs)))
- (message
- "Production %s: %S"
production-index
- production)
- (push
- (reverse new-rhs)
- new-value)
- (puthash
- lhs
- (reverse new-value)
- parser-generator--table-productions-rhs))
- (setq
- rhs-element-index
- (1+ rhs-element-index))
- (puthash
- production
- production-index
- parser-generator--table-productions-number)
- (puthash
- production-index
- production
- parser-generator--table-productions-number-reverse)
- (push
- production
- new-productions)
- (when translation
- (parser-generator--debug
- (message
- "Translation %s: %s"
- production-index
- translation))
+ parser-generator--table-productions-number)
(puthash
production-index
- translation
- parser-generator--table-translations))
- (setq
- production-index
- (1+ production-index))))))
+ production
+ parser-generator--table-productions-number-reverse)
+ (push
+ production
+ new-productions)
+ (when translation
+ (parser-generator--debug
+ (message
+ "Translation %S: %S"
+ production-index
+ translation))
+ (puthash
+ production-index
+ translation
+ parser-generator--table-translations))
+ (setq
+ production-index
+ (1+ production-index)))))))
(setq
new-productions
(nreverse new-productions))
- [elpa] externals/parser-generator c4c68b2 302/434: Added progress-indicator to goto-table generation, (continued)
- [elpa] externals/parser-generator c4c68b2 302/434: Added progress-indicator to goto-table generation, ELPA Syncer, 2021/11/29
- [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 <=
- [elpa] externals/parser-generator c6d3ad2 352/434: Infix calculator working as expected without precedence rules, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 21948c8 358/434: Fixed lex-analyzer to infix calculator test to support white-space and floats, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 14711d4 363/434: Added more debug stuff, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator f0f2daa 364/434: Started refactor of context-sensitive attributes, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 7e1d2fb 368/434: Added TODO notes, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 5a1f09a 369/434: More work on adding support for production number related precedence, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator e4658d9 372/434: LR action-table generation is now using context-sensitive precedence resolution for reduce/reduce conflicts, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 6aff9d0 373/434: Made TODO notes, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 831a6e6 379/434: Made a commentary audit of parse according to GOTO and ACTION tables, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator bff0e63 380/434: Added TODO note, ELPA Syncer, 2021/11/29