aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2022-05-22 12:21:23 -0400
committerStefan Monnier2022-05-22 12:21:23 -0400
commit3294ad44ebcd024b4ada68d00bedca33acc52de6 (patch)
treecbed468afa2ab2ed15f8a587b8f3b1f584dda2d8
parenta1a6e6c5c44e0930784de67fc6b25c3cc43e0ee4 (diff)
downloademacs-3294ad44ebcd024b4ada68d00bedca33acc52de6.tar.gz
emacs-3294ad44ebcd024b4ada68d00bedca33acc52de6.zip
wisent.el: Prefer `define-mode-local-override`
* lisp/cedet/semantic/wisent.el (wisent--parse-stream): Rename from `wisent-parse-stream` and mark the old name obsolete. (semantic-parse-stream): Override with `define-mode-local-override`. * lisp/cedet/semantic/wisent/grammar.el (semantic-grammar-setupcode-builder): Don't override `semantic-parse-stream` manually here via `semantic-install-function-overrides`. * lisp/cedet/semantic/grm-wy-boot.el: Refresh.
-rw-r--r--lisp/cedet/semantic/grm-wy-boot.el2
-rw-r--r--lisp/cedet/semantic/wisent.el23
-rw-r--r--lisp/cedet/semantic/wisent/grammar.el4
3 files changed, 15 insertions, 14 deletions
diff --git a/lisp/cedet/semantic/grm-wy-boot.el b/lisp/cedet/semantic/grm-wy-boot.el
index 376fab89c23..6525a10443b 100644
--- a/lisp/cedet/semantic/grm-wy-boot.el
+++ b/lisp/cedet/semantic/grm-wy-boot.el
@@ -422,8 +422,6 @@
422 422
423(defun semantic-grammar-wy--install-parser () 423(defun semantic-grammar-wy--install-parser ()
424 "Setup the Semantic Parser." 424 "Setup the Semantic Parser."
425 (semantic-install-function-overrides
426 '((semantic-parse-stream . wisent-parse-stream)))
427 (setq semantic-parser-name "LALR" 425 (setq semantic-parser-name "LALR"
428 semantic--parse-table semantic-grammar-wy--parse-table 426 semantic--parse-table semantic-grammar-wy--parse-table
429 semantic-debug-parser-source "grammar.wy" 427 semantic-debug-parser-source "grammar.wy"
diff --git a/lisp/cedet/semantic/wisent.el b/lisp/cedet/semantic/wisent.el
index 55eeef453ea..d06028b48f7 100644
--- a/lisp/cedet/semantic/wisent.el
+++ b/lisp/cedet/semantic/wisent.el
@@ -154,17 +154,25 @@ and will be collected in `semantic-lex' form: (SYMBOL START . END)."
154;; Maybe the latter is faster because it eliminates a lot of function 154;; Maybe the latter is faster because it eliminates a lot of function
155;; call. 155;; call.
156;; 156;;
157(defun wisent-parse-stream (stream goal) 157;; Emacs<29 generated grammars which manually setup `wisent-parse-stream'
158;; as a buffer-local overload for `semantic-parse-stream', but we don't
159;; need that now that we define a mode-local overload instead.
160(define-obsolete-function-alias 'wisent-parse-stream
161 #'wisent--parse-stream "29.1"
162 "Recompile your grammars so they don't call `wisent-parse-stream' any more.")
163(define-mode-local-override semantic-parse-stream semantic-grammar-mode
164 (stream goal)
165 "Parse STREAM using the Wisent LALR parser.
166See `wisent--parse-stream'."
167 (wisent--parse-stream stream goal))
168(defun wisent--parse-stream (stream goal)
158 "Parse STREAM using the Wisent LALR parser. 169 "Parse STREAM using the Wisent LALR parser.
159GOAL is a nonterminal symbol to start parsing at. 170GOAL is a nonterminal symbol to start parsing at.
160Return the list (STREAM SEMANTIC-STREAM) where STREAM are those 171Return the list (STREAM SEMANTIC-STREAM) where STREAM are those
161elements of STREAM that have not been used. SEMANTIC-STREAM is the 172elements of STREAM that have not been used. SEMANTIC-STREAM is the
162list of semantic tags found. 173list of semantic tags found.
163The LALR parser automaton must be available in buffer local variable 174The LALR parser automaton must be available in buffer local variable
164`semantic--parse-table'. 175`semantic--parse-table'."
165
166Must be installed by `semantic-install-function-overrides' to override
167the standard function `semantic-parse-stream'."
168 (let (wisent-lex-istream wisent-lex-lookahead la-elt cache) 176 (let (wisent-lex-istream wisent-lex-lookahead la-elt cache)
169 177
170 ;; IMPLEMENTATION NOTES: 178 ;; IMPLEMENTATION NOTES:
@@ -267,10 +275,7 @@ Optional arguments GOAL is a nonterminal symbol to start parsing at,
267DEPTH is the lexical depth to scan, and RETURNONERROR is a flag to 275DEPTH is the lexical depth to scan, and RETURNONERROR is a flag to
268stop parsing on syntax error, when non-nil. 276stop parsing on syntax error, when non-nil.
269The LALR parser automaton must be available in buffer local variable 277The LALR parser automaton must be available in buffer local variable
270`semantic--parse-table'. 278`semantic--parse-table'."
271
272Must be installed by `semantic-install-function-overrides' to override
273the standard function `semantic-parse-region'."
274 (if (or (< start (point-min)) (> end (point-max)) (< end start)) 279 (if (or (< start (point-min)) (> end (point-max)) (< end start))
275 (error "Invalid bounds [%s %s] passed to `wisent-parse-region'" 280 (error "Invalid bounds [%s %s] passed to `wisent-parse-region'"
276 start end)) 281 start end))
diff --git a/lisp/cedet/semantic/wisent/grammar.el b/lisp/cedet/semantic/wisent/grammar.el
index a4104e333d3..3d83ee197de 100644
--- a/lisp/cedet/semantic/wisent/grammar.el
+++ b/lisp/cedet/semantic/wisent/grammar.el
@@ -295,9 +295,7 @@ Return the expanded expression."
295 wisent-grammar-mode () 295 wisent-grammar-mode ()
296 "Return the parser setup code." 296 "Return the parser setup code."
297 (format 297 (format
298 "(semantic-install-function-overrides\n\ 298 "(setq semantic-parser-name \"LALR\"\n\
299 '((semantic-parse-stream . wisent-parse-stream)))\n\
300 (setq semantic-parser-name \"LALR\"\n\
301 semantic--parse-table %s\n\ 299 semantic--parse-table %s\n\
302 semantic-debug-parser-source %S\n\ 300 semantic-debug-parser-source %S\n\
303 semantic-flex-keywords-obarray %s\n\ 301 semantic-flex-keywords-obarray %s\n\