[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/parser-generator 53c09f7 119/434: Added hash-table for

From: ELPA Syncer
Subject: [elpa] externals/parser-generator 53c09f7 119/434: Added hash-table for productions indexed by production-number
Date: Mon, 29 Nov 2021 15:59:21 -0500 (EST)

branch: externals/parser-generator
commit 53c09f755b637e07687ba99676c870e8a95cdc3e
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Added hash-table for productions indexed by production-number
 parser.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/parser.el b/parser.el
index 4e6ca78..dd7df4a 100644
--- a/parser.el
+++ b/parser.el
@@ -53,6 +53,10 @@
   "Hash-table indexed by production and value is production-number.")
+(defvar parser--table-productions-number-reverse
+  nil
+  "Hash-table indexed by production-number and value is production.")
 (defvar parser--table-terminal-p
   "Hash-table of non-terminals for quick checking.")
@@ -153,9 +157,15 @@
 (defun parser--get-grammar-production-number (production)
   "If PRODUCTION exist, return it's number."
   (unless parser--table-productions-number
-    (error "Table for production numbers is undefined!"))
+    (error "Table for production-numbers is undefined!"))
   (gethash production parser--table-productions-number))
+(defun parser--get-grammar-production-by-number (production-number)
+  "If PRODUCTION-NUMBER exist, return it's production."
+  (unless parser--table-productions-number-reverse
+    (error "Table for reverse production-numbers is undefined!"))
+  (gethash production-number parser--table-productions-number-reverse))
 (defun parser--get-grammar-productions (&optional G)
   "Return productions of grammar G."
   (unless G
@@ -237,6 +247,7 @@
           (puthash lhs (nreverse new-value) parser--table-productions-rhs))))
     (setq parser--table-productions-number (make-hash-table :test 'equal))
+    (setq parser--table-productions-number-reverse (make-hash-table :test 
     (let ((production-index 0))
       (dolist (p productions)
         (let ((lhs (car p))
@@ -249,6 +260,7 @@
              (message "Production %s: %s" production-index production))
             (puthash production production-index 
+            (puthash production-index production 
             (setq production-index (1+ production-index)))))))
   (let ((look-aheads (parser--get-grammar-look-aheads)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]