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

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

[elpa] externals/parser-generator 7584880 298/434: Added failing unit te


From: ELPA Syncer
Subject: [elpa] externals/parser-generator 7584880 298/434: Added failing unit test for calculating FIRST in grammar with cycles
Date: Mon, 29 Nov 2021 16:00:02 -0500 (EST)

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

    Added failing unit test for calculating FIRST in grammar with cycles
---
 parser-generator.el           | 15 ++++++++++-----
 test/parser-generator-test.el | 19 +++++++++++++++++++
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/parser-generator.el b/parser-generator.el
index ad5c190..33c48c9 100644
--- a/parser-generator.el
+++ b/parser-generator.el
@@ -824,7 +824,7 @@
                 (setq
                  expanded-all-second
                  t))
-              (when (> i 1000)
+              (when (> i 100)
                 (error "Endless loop!"))
               (parser-generator--debug (message "i = %s" i))
               (setq
@@ -915,12 +915,13 @@
                                 production-lhs
                                 f-set)))
 
-                          ;; If another set has not been fully expanded
+                          ;; If another RHS has not been fully expanded
                           ;; mark LHS as not fully expanded
                           (unless (nth 0 existing-f-set)
                             (parser-generator--debug
                              (message
-                              "Expanded-all negative set because a sub-set 
'%s' is not fully expanded"
+                              "Expanded-all negative set for LHS '%s' because 
a alternative RHS '%s' is not fully expanded"
+                              production-lhs
                               existing-f-set))
                             (setq
                              expanded-all
@@ -1137,7 +1138,9 @@
                                (not (equal lhs (list rhs-element))))
                           (parser-generator--debug
                            (message
-                            "Expanded-all negative set because sub-terminals 
of '%s' has not been fully expanded" rhs-element))
+                            "Expanded-all negative set for '%s' because 
sub-terminals of '%s' has not been fully expanded"
+                            lhs
+                            rhs-element))
                           (setq
                            expanded-all
                            nil))
@@ -1305,7 +1308,9 @@
 
                     (parser-generator--debug
                      (message
-                      "Expanded-all negative set because symbol '%s' is a 
non-terminal and i is zero" rhs-element))
+                      "Expanded-all negative set for '%s' because symbol '%s' 
is a non-terminal and i is zero"
+                      lhs
+                      rhs-element))
                     (setq
                      expanded-all
                      nil)
diff --git a/test/parser-generator-test.el b/test/parser-generator-test.el
index 6d23e5e..16165ea 100644
--- a/test/parser-generator-test.el
+++ b/test/parser-generator-test.el
@@ -383,6 +383,25 @@
     (parser-generator--first 'S)))
   (message "Passed first 9 with complex grammar with starting e-identifier 
variant 2")
 
+  (parser-generator-set-grammar
+   '(
+     (Sp S A B)
+     (a b c)
+     (
+      (Sp S)
+      (S A B)
+      (A (a b A) (B c))
+      (B S c)
+      )
+     Sp))
+  (parser-generator-set-look-ahead-number 1)
+  (parser-generator-process-grammar)
+  (should
+   (equal
+    '((a) (c))
+    (parser-generator--first 'Sp)))
+  (message "Passed first 10 with complex grammar that contains cyclic loops")
+
   (message "Passed tests for (parser-generator--first)"))
 
 (defun parser-generator-test--e-free-first ()



reply via email to

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