emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/parser-generator 1818b9d 199/434: Added error in action


From: ELPA Syncer
Subject: [elpa] externals/parser-generator 1818b9d 199/434: Added error in action-tables generation if no accept action is found
Date: Mon, 29 Nov 2021 15:59:40 -0500 (EST)

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

    Added error in action-tables generation if no accept action is found
---
 parser-generator-lr.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/parser-generator-lr.el b/parser-generator-lr.el
index c6078bd..b5b9896 100644
--- a/parser-generator-lr.el
+++ b/parser-generator-lr.el
@@ -40,7 +40,8 @@
   (let ((action-tables)
         (states '(shift reduce error))
         (added-actions (make-hash-table :test 'equal))
-        (goto-tables (parser-generator--hash-to-list 
parser-generator-lr--goto-tables)))
+        (goto-tables (parser-generator--hash-to-list 
parser-generator-lr--goto-tables))
+        (found-accept))
     (dolist (goto-table goto-tables)
       (let ((goto-index (car goto-table))
             (found-action nil)
@@ -103,11 +104,13 @@
                             (unless (gethash hash-key added-actions)
                               (puthash hash-key t added-actions)
                               (let ((production (list A B)))
-                                (let ((production-number 
(parser-generator--get-grammar-production-number production)))
+                                (let ((production-number
+                                       
(parser-generator--get-grammar-production-number production)))
                                   (unless production-number
                                     (error "Expecting production number for %s 
from LR-item %s!" production lr-item))
 
                                   (if (and
+                                       (= production-number 0)
                                        (>= (length u) 1)
                                        (parser-generator--valid-e-p
                                         (nth (1- (length u)) u)))
@@ -116,6 +119,7 @@
                                         ;; of empty look-ahead means grammar 
has been accepted
                                         (message "accept of %s" u)
                                         (push (list u 'accept) action-table)
+                                        (setq found-accept t)
                                         (setq found-action t))
 
                                     (message "no accept of %s, p: %s" u 
production-number)
@@ -133,6 +137,8 @@
          (message "%s actions %s" goto-index action-table))
         (when action-table
           (push (list goto-index (sort action-table 
'parser-generator--sort-list)) action-tables))))
+    (unless found-accept
+      (error "Failed to find a accept action in generated action-tables: %s 
from goto-tabbles: %s" action-tables goto-tables))
     (setq action-tables (nreverse action-tables))
     (setq parser-generator-lr--action-tables (make-hash-table :test 'equal))
     (let ((table-length (length action-tables))



reply via email to

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