1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-24 06:20:43 -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 () (defun semantic-grammar-wy--install-parser ()
"Setup the Semantic Parser." "Setup the Semantic Parser."
(semantic-install-function-overrides
'((semantic-parse-stream . wisent-parse-stream)))
(setq semantic-parser-name "LALR" (setq semantic-parser-name "LALR"
semantic--parse-table semantic-grammar-wy--parse-table semantic--parse-table semantic-grammar-wy--parse-table
semantic-debug-parser-source "grammar.wy" 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 ;; Maybe the latter is faster because it eliminates a lot of function
;; call. ;; 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. "Parse STREAM using the Wisent LALR parser.
GOAL is a nonterminal symbol to start parsing at. GOAL is a nonterminal symbol to start parsing at.
Return the list (STREAM SEMANTIC-STREAM) where STREAM are those Return the list (STREAM SEMANTIC-STREAM) where STREAM are those
elements of STREAM that have not been used. SEMANTIC-STREAM is the elements of STREAM that have not been used. SEMANTIC-STREAM is the
list of semantic tags found. list of semantic tags found.
The LALR parser automaton must be available in buffer local variable The LALR parser automaton must be available in buffer local variable
`semantic--parse-table'. `semantic--parse-table'."
Must be installed by `semantic-install-function-overrides' to override
the standard function `semantic-parse-stream'."
(let (wisent-lex-istream wisent-lex-lookahead la-elt cache) (let (wisent-lex-istream wisent-lex-lookahead la-elt cache)
;; IMPLEMENTATION NOTES: ;; 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 DEPTH is the lexical depth to scan, and RETURNONERROR is a flag to
stop parsing on syntax error, when non-nil. stop parsing on syntax error, when non-nil.
The LALR parser automaton must be available in buffer local variable The LALR parser automaton must be available in buffer local variable
`semantic--parse-table'. `semantic--parse-table'."
Must be installed by `semantic-install-function-overrides' to override
the standard function `semantic-parse-region'."
(if (or (< start (point-min)) (> end (point-max)) (< end start)) (if (or (< start (point-min)) (> end (point-max)) (< end start))
(error "Invalid bounds [%s %s] passed to `wisent-parse-region'" (error "Invalid bounds [%s %s] passed to `wisent-parse-region'"
start end)) start end))

View file

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