emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 3294ad44eb 3/4: wisent.el: Prefer `define-mode-local-override`


From: Stefan Monnier
Subject: master 3294ad44eb 3/4: wisent.el: Prefer `define-mode-local-override`
Date: Sun, 22 May 2022 12:22:57 -0400 (EDT)

branch: master
commit 3294ad44ebcd024b4ada68d00bedca33acc52de6
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    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.
---
 lisp/cedet/semantic/grm-wy-boot.el    |  2 --
 lisp/cedet/semantic/wisent.el         | 23 ++++++++++++++---------
 lisp/cedet/semantic/wisent/grammar.el |  4 +---
 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 376fab89c2..6525a10443 100644
--- a/lisp/cedet/semantic/grm-wy-boot.el
+++ b/lisp/cedet/semantic/grm-wy-boot.el
@@ -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"
diff --git a/lisp/cedet/semantic/wisent.el b/lisp/cedet/semantic/wisent.el
index 55eeef453e..d06028b48f 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)."
 ;; 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))
diff --git a/lisp/cedet/semantic/wisent/grammar.el 
b/lisp/cedet/semantic/wisent/grammar.el
index a4104e333d..3d83ee197d 100644
--- a/lisp/cedet/semantic/wisent/grammar.el
+++ b/lisp/cedet/semantic/wisent/grammar.el
@@ -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\



reply via email to

[Prev in Thread] Current Thread [Next in Thread]