aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-06-18 16:05:08 +0200
committerLars Ingebrigtsen2019-06-18 16:05:08 +0200
commitf21ec24524c705e18674a2e9e4db37b11fa3ebab (patch)
tree4d3f1ad27a88122e2e2a965dfd05edcdbb2e8a55
parent90b44f336caf7d70721f44ac2497a38ff69d6c7d (diff)
downloademacs-f21ec24524c705e18674a2e9e4db37b11fa3ebab.tar.gz
emacs-f21ec24524c705e18674a2e9e4db37b11fa3ebab.zip
Add a mechanism to specify expected shift/reduce .wy conflicts
* admin/grammars/python.wy: Set the expected number of shift/reduce conflicts to four. * lisp/cedet/semantic/grammar.el (semantic-grammar-expected-conflicts): New function. * lisp/cedet/semantic/wisent/comp.el (wisent-total-conflicts): Use it to suppress warnings about the expected number of shift/reduce conflicts.
-rw-r--r--admin/grammars/python.wy1
-rw-r--r--lisp/cedet/semantic/grammar.el9
-rw-r--r--lisp/cedet/semantic/wisent/comp.el18
3 files changed, 20 insertions, 8 deletions
diff --git a/admin/grammars/python.wy b/admin/grammars/python.wy
index 082850df59c..0e926ad3636 100644
--- a/admin/grammars/python.wy
+++ b/admin/grammars/python.wy
@@ -88,6 +88,7 @@
88 88
89%package wisent-python-wy 89%package wisent-python-wy
90%provide semantic/wisent/python-wy 90%provide semantic/wisent/python-wy
91%expectedconflicts 4
91 92
92%{ 93%{
93(declare-function wisent-python-reconstitute-function-tag 94(declare-function wisent-python-reconstitute-function-tag
diff --git a/lisp/cedet/semantic/grammar.el b/lisp/cedet/semantic/grammar.el
index 8ffa4c6d83e..39161420f98 100644
--- a/lisp/cedet/semantic/grammar.el
+++ b/lisp/cedet/semantic/grammar.el
@@ -277,6 +277,13 @@ foo.by it is foo-by."
277 (i (string-match (format "\\([.]\\)%s\\'" ext) file))) 277 (i (string-match (format "\\([.]\\)%s\\'" ext) file)))
278 (concat (substring file 0 i) "-" ext)))) 278 (concat (substring file 0 i) "-" ext))))
279 279
280(defun semantic-grammar-expected-conflicts ()
281 "Return the number of expected shift/reduce conflicts in the package."
282 (let ((conflicts (semantic-grammar-tag-symbols 'expectedconflicts)))
283 (if conflicts
284 (string-to-number conflicts)
285 0)))
286
280(defsubst semantic-grammar-languagemode () 287(defsubst semantic-grammar-languagemode ()
281 "Return the %languagemode value as a list of symbols or nil." 288 "Return the %languagemode value as a list of symbols or nil."
282 (semantic-grammar-tag-symbols 'languagemode)) 289 (semantic-grammar-tag-symbols 'languagemode))
@@ -987,7 +994,7 @@ Return non-nil if there were no errors, nil if errors."
987 (vc-handled-backends nil)) 994 (vc-handled-backends nil))
988 (setq semanticdb-new-database-class 'semanticdb-project-database) 995 (setq semanticdb-new-database-class 'semanticdb-project-database)
989 (semantic-mode 1) 996 (semantic-mode 1)
990 (semantic-grammar-create-package))) 997 (semantic-grammar-create-package t)))
991 (error 998 (error
992 (message "%s" (error-message-string err)) 999 (message "%s" (error-message-string err))
993 nil)))) 1000 nil))))
diff --git a/lisp/cedet/semantic/wisent/comp.el b/lisp/cedet/semantic/wisent/comp.el
index 051b898ed78..ff434f555da 100644
--- a/lisp/cedet/semantic/wisent/comp.el
+++ b/lisp/cedet/semantic/wisent/comp.el
@@ -2264,24 +2264,28 @@ there are any reduce/reduce conflicts."
2264 :group 'wisent 2264 :group 'wisent
2265 :type '(choice (const nil) integer)) 2265 :type '(choice (const nil) integer))
2266 2266
2267(declare-function semantic-grammar-expected-conflicts "semantic/grammar")
2268
2267(defun wisent-total-conflicts () 2269(defun wisent-total-conflicts ()
2268 "Report the total number of conflicts." 2270 "Report the total number of conflicts."
2271 (require 'semantic/grammar)
2269 (unless (and (zerop rrc-total) 2272 (unless (and (zerop rrc-total)
2270 (or (zerop src-total) 2273 (or (zerop src-total)
2271 (= src-total (or wisent-expected-conflicts 0)))) 2274 (= src-total (or wisent-expected-conflicts 0))))
2272 (let* ((src (wisent-source)) 2275 (let* ((src (wisent-source))
2273 (src (if src (concat " in " src) "")) 2276 (src (if src (concat " in " src) ""))
2274 (msg (format "Grammar%s contains" src))) 2277 (msg (format "Grammar%s contains" src)))
2275 (if (> src-total 0) 2278 (when (and (> src-total 0)
2276 (setq msg (format "%s %d shift/reduce conflict%s" 2279 (not (= rrc-total (semantic-grammar-expected-conflicts))))
2277 msg src-total (if (> src-total 1) 2280 (setq msg (format "%s %d shift/reduce conflict%s"
2278 "s" "")))) 2281 msg src-total (if (> src-total 1)
2282 "s" ""))))
2279 (if (and (> src-total 0) (> rrc-total 0)) 2283 (if (and (> src-total 0) (> rrc-total 0))
2280 (setq msg (format "%s and" msg))) 2284 (setq msg (format "%s and" msg)))
2281 (if (> rrc-total 0) 2285 (if (> rrc-total 0)
2282 (setq msg (format "%s %d reduce/reduce conflict%s" 2286 (setq msg (format "%s %d reduce/reduce conflict%s"
2283 msg rrc-total (if (> rrc-total 1) 2287 msg rrc-total (if (> rrc-total 1)
2284 "s" "")))) 2288 "s" ""))))
2285 (message msg)))) 2289 (message msg))))
2286 2290
2287(defun wisent-print-conflicts () 2291(defun wisent-print-conflicts ()