summaryrefslogtreecommitdiff
path: root/lisp/cedet/semantic/grammar.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2019-06-19 13:47:22 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2019-06-19 13:48:49 +0200
commit390b4bc1e25fe691548d7ec982eb2f7027fe26a3 (patch)
tree3355d4c19e87fbe9814339a7f82cb30bd458fadd /lisp/cedet/semantic/grammar.el
parenteef48e124da251605ea05579aac196f2f8e2f534 (diff)
downloademacs-390b4bc1e25fe691548d7ec982eb2f7027fe26a3.tar.gz
Allow specifying the expected number of shift/reduce conflicts
* admin/grammars/grammar.wy: Add %expectedconflicts. * lisp/cedet/semantic/grammar-wy.el (semantic-grammar-wy--keyword-table): Ditto. * lisp/cedet/semantic/grammar.el (semantic-grammar-expected-conflicts): New function. (semantic-grammar-insert-defconst-with-eval): New function. (semantic-grammar-create-package): Output the number of expected shift/reduce conflicts. * lisp/cedet/semantic/wisent/comp.el (wisent-total-conflicts): Don't output the warning if the number of shift/reduce conflicts is expected. (wisent-expected-conflicts): Made obsolete.
Diffstat (limited to 'lisp/cedet/semantic/grammar.el')
-rw-r--r--lisp/cedet/semantic/grammar.el20
1 files changed, 19 insertions, 1 deletions
diff --git a/lisp/cedet/semantic/grammar.el b/lisp/cedet/semantic/grammar.el
index 8ffa4c6d83e..3c35583dd3c 100644
--- a/lisp/cedet/semantic/grammar.el
+++ b/lisp/cedet/semantic/grammar.el
@@ -277,6 +277,10 @@ foo.by it is foo-by."
(i (string-match (format "\\([.]\\)%s\\'" ext) file)))
(concat (substring file 0 i) "-" ext))))
+(defun semantic-grammar-expected-conflicts ()
+ "Return the number of expected shift/reduce conflicts in the package."
+ (semantic-grammar-tag-symbols 'expectedconflicts))
+
(defsubst semantic-grammar-languagemode ()
"Return the %languagemode value as a list of symbols or nil."
(semantic-grammar-tag-symbols 'languagemode))
@@ -533,6 +537,14 @@ Also load the specified macro libraries."
(goto-char start)
(indent-sexp))))
+(defun semantic-grammar-insert-defconst-with-eval (name value docstring)
+ "Insert declaration of constant NAME with VALUE and DOCSTRING."
+ (let ((start (point)))
+ (insert (format "(eval-and-compile (defconst %s\n%s%S))\n\n" name value docstring))
+ (save-excursion
+ (goto-char start)
+ (indent-sexp))))
+
(defun semantic-grammar-insert-defun (name body docstring)
"Insert declaration of function NAME with BODY and DOCSTRING."
(let ((start (point)))
@@ -890,6 +902,12 @@ Lisp code."
(insert " \n;;; Declarations\n;;\n")
+ (semantic-grammar-insert-defconst-with-eval
+ (concat semantic--grammar-package "--expected-conflicts")
+ (with-current-buffer semantic--grammar-input-buffer
+ (format "%s\n" (car (semantic-grammar-expected-conflicts))))
+ "The number of expected shift/reduce conflicts in this grammar.")
+
;; `eval-defun' is not necessary to reset `defconst' values.
(semantic-grammar-insert-defconst
(semantic-grammar-keywordtable)
@@ -987,7 +1005,7 @@ Return non-nil if there were no errors, nil if errors."
(vc-handled-backends nil))
(setq semanticdb-new-database-class 'semanticdb-project-database)
(semantic-mode 1)
- (semantic-grammar-create-package)))
+ (semantic-grammar-create-package t)))
(error
(message "%s" (error-message-string err))
nil))))