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

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

[elpa] externals/parser-generator 4404424 367/434: Added test for parsin


From: ELPA Syncer
Subject: [elpa] externals/parser-generator 4404424 367/434: Added test for parsing context-sensitive attributes
Date: Mon, 29 Nov 2021 16:00:17 -0500 (EST)

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

    Added test for parsing context-sensitive attributes
---
 parser-generator.el           |  4 ++--
 test/parser-generator-test.el | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/parser-generator.el b/parser-generator.el
index d8812e4..34a4b73 100644
--- a/parser-generator.el
+++ b/parser-generator.el
@@ -563,8 +563,8 @@
                           (progn
                             (when (=
                                    sub-rhs-element-index
-                                   (1- sub-rhs-element-length)
-                                   (error "Expecting value for 
context-sensitive attribute!")))
+                                   (1- sub-rhs-element-length))
+                              (error "Expecting value for context-sensitive 
attribute %S!" sub-rhs-element))
                             (let ((attribute-value
                                    (nth
                                     (1+ sub-rhs-element-index)
diff --git a/test/parser-generator-test.el b/test/parser-generator-test.el
index bc311e9..7e9a996 100644
--- a/test/parser-generator-test.el
+++ b/test/parser-generator-test.el
@@ -469,6 +469,42 @@
 
   (message "Passed tests for (parser-generator--empty-free-first)"))
 
+(defun 
parser-generator-test--get-grammar-context-sensitive-attributes-by-production-number
 ()
+  "Test 
`parser-generator--get-grammar-context-sensitive-attributes-by-production-number'."
+  (message "Starting tests for 
(parser-generator--get-grammar-context-sensitive-attributes-by-production-number)")
+  (setq
+   parser-generator--context-sensitive-attributes
+   '(%prec))
+  (parser-generator-set-grammar '((A B C) ("a" "b" "c") ((A ("a" %prec 1) ("b" 
"c" %prec D))) A))
+  (parser-generator-process-grammar)
+
+  (should
+   (equal
+    '((%prec 1))
+    
(parser-generator--get-grammar-context-sensitive-attributes-by-production-number
 0)))
+  (should
+   (equal
+    '((A) ("a"))
+    (parser-generator--get-grammar-production-by-number 0)))
+  (should
+   (equal
+    '((%prec D))
+    
(parser-generator--get-grammar-context-sensitive-attributes-by-production-number
 1)))
+  (should
+   (equal
+    '((A) ("b" "c"))
+    (parser-generator--get-grammar-production-by-number 1)))
+  (should
+   (equal
+    nil
+    
(parser-generator--get-grammar-context-sensitive-attributes-by-production-number
 2)))
+  (should
+   (equal
+    nil
+    (parser-generator--get-grammar-production-by-number 2)))
+
+  (message "Passed tests for 
(parser-generator--get-grammar-context-sensitive-attributes-by-production-number)"))
+
 (defun parser-generator-test--valid-grammar-p ()
   "Test function `parser-generator--valid-grammar-p'."
   (message "Starting tests for (parser-generator--valid-grammar-p)")
@@ -917,6 +953,7 @@
   (parser-generator-test--valid-context-sensitive-attribute-p)
   (parser-generator-test--valid-context-sensitive-attributes-p)
   (parser-generator-test--valid-grammar-p)
+  
(parser-generator-test--get-grammar-context-sensitive-attributes-by-production-number)
   (parser-generator-test--valid-look-ahead-number-p)
   (parser-generator-test--valid-look-ahead-p)
   (parser-generator-test--valid-non-terminal-p)



reply via email to

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