aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-06-18 15:56:18 +0200
committerLars Ingebrigtsen2019-06-18 15:56:18 +0200
commitd715ae8788e16b22f7f68cb82b51a40ad95c78c2 (patch)
tree38dc3b3f14c2074456e909de00761d5aa57998a3
parente09fcc1ff33c0643e9100cb5eee5ff351a85fcbb (diff)
downloademacs-d715ae8788e16b22f7f68cb82b51a40ad95c78c2.tar.gz
emacs-d715ae8788e16b22f7f68cb82b51a40ad95c78c2.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.el16
3 files changed, 18 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..733345f593f 100644
--- a/lisp/cedet/semantic/wisent/comp.el
+++ b/lisp/cedet/semantic/wisent/comp.el
@@ -40,6 +40,7 @@
40 40
41;;; Code: 41;;; Code:
42(require 'semantic/wisent) 42(require 'semantic/wisent)
43(require 'semantic/grammar)
43(eval-when-compile (require 'cl-lib)) 44(eval-when-compile (require 'cl-lib))
44 45
45;;;; ------------------- 46;;;; -------------------
@@ -2272,16 +2273,17 @@ there are any reduce/reduce conflicts."
2272 (let* ((src (wisent-source)) 2273 (let* ((src (wisent-source))
2273 (src (if src (concat " in " src) "")) 2274 (src (if src (concat " in " src) ""))
2274 (msg (format "Grammar%s contains" src))) 2275 (msg (format "Grammar%s contains" src)))
2275 (if (> src-total 0) 2276 (when (and (> src-total 0)
2276 (setq msg (format "%s %d shift/reduce conflict%s" 2277 (not (= rrc-total (semantic-grammar-expected-conflicts))))
2277 msg src-total (if (> src-total 1) 2278 (setq msg (format "%s %d shift/reduce conflict%s"
2278 "s" "")))) 2279 msg src-total (if (> src-total 1)
2280 "s" ""))))
2279 (if (and (> src-total 0) (> rrc-total 0)) 2281 (if (and (> src-total 0) (> rrc-total 0))
2280 (setq msg (format "%s and" msg))) 2282 (setq msg (format "%s and" msg)))
2281 (if (> rrc-total 0) 2283 (if (> rrc-total 0)
2282 (setq msg (format "%s %d reduce/reduce conflict%s" 2284 (setq msg (format "%s %d reduce/reduce conflict%s"
2283 msg rrc-total (if (> rrc-total 1) 2285 msg rrc-total (if (> rrc-total 1)
2284 "s" "")))) 2286 "s" ""))))
2285 (message msg)))) 2287 (message msg))))
2286 2288
2287(defun wisent-print-conflicts () 2289(defun wisent-print-conflicts ()