(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"
;; 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:
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))
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\