1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

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.
This commit is contained in:
Stefan Monnier 2022-05-22 12:21:23 -04:00
parent a1a6e6c5c4
commit 3294ad44eb
3 changed files with 15 additions and 14 deletions

View file

@ -422,8 +422,6 @@
(defun semantic-grammar-wy--install-parser ()
"Setup the Semantic Parser."
(semantic-install-function-overrides
'((semantic-parse-stream . wisent-parse-stream)))
(setq semantic-parser-name "LALR"
semantic--parse-table semantic-grammar-wy--parse-table
semantic-debug-parser-source "grammar.wy"

View file

@ -154,17 +154,25 @@ and will be collected in `semantic-lex' form: (SYMBOL START . END)."
;; Maybe the latter is faster because it eliminates a lot of function
;; call.
;;
(defun wisent-parse-stream (stream goal)
;; Emacs<29 generated grammars which manually setup `wisent-parse-stream'
;; as a buffer-local overload for `semantic-parse-stream', but we don't
;; need that now that we define a mode-local overload instead.
(define-obsolete-function-alias 'wisent-parse-stream
#'wisent--parse-stream "29.1"
"Recompile your grammars so they don't call `wisent-parse-stream' any more.")
(define-mode-local-override semantic-parse-stream semantic-grammar-mode
(stream goal)
"Parse STREAM using the Wisent LALR parser.
See `wisent--parse-stream'."
(wisent--parse-stream stream goal))
(defun wisent--parse-stream (stream goal)
"Parse STREAM using the Wisent LALR parser.
GOAL is a nonterminal symbol to start parsing at.
Return the list (STREAM SEMANTIC-STREAM) where STREAM are those
elements of STREAM that have not been used. SEMANTIC-STREAM is the
list of semantic tags found.
The LALR parser automaton must be available in buffer local variable
`semantic--parse-table'.
Must be installed by `semantic-install-function-overrides' to override
the standard function `semantic-parse-stream'."
`semantic--parse-table'."
(let (wisent-lex-istream wisent-lex-lookahead la-elt cache)
;; IMPLEMENTATION NOTES:
@ -267,10 +275,7 @@ Optional arguments GOAL is a nonterminal symbol to start parsing at,
DEPTH is the lexical depth to scan, and RETURNONERROR is a flag to
stop parsing on syntax error, when non-nil.
The LALR parser automaton must be available in buffer local variable
`semantic--parse-table'.
Must be installed by `semantic-install-function-overrides' to override
the standard function `semantic-parse-region'."
`semantic--parse-table'."
(if (or (< start (point-min)) (> end (point-max)) (< end start))
(error "Invalid bounds [%s %s] passed to `wisent-parse-region'"
start end))

View file

@ -295,9 +295,7 @@ Return the expanded expression."
wisent-grammar-mode ()
"Return the parser setup code."
(format
"(semantic-install-function-overrides\n\
'((semantic-parse-stream . wisent-parse-stream)))\n\
(setq semantic-parser-name \"LALR\"\n\
"(setq semantic-parser-name \"LALR\"\n\
semantic--parse-table %s\n\
semantic-debug-parser-source %S\n\
semantic-flex-keywords-obarray %s\n\