aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2021-03-07 01:58:16 -0500
committerStefan Monnier2021-03-07 01:58:16 -0500
commit468bb5ab7f949441f68c4133fcd5292dfbbfd83d (patch)
tree865d0697dc016cda1cfaf7b267fe6ddd7780e55d
parent856a0a913a1932e1bad8e44d34944ce7504b23ff (diff)
downloademacs-468bb5ab7f949441f68c4133fcd5292dfbbfd83d.tar.gz
emacs-468bb5ab7f949441f68c4133fcd5292dfbbfd83d.zip
* lisp/cedet/semantic/wisent: Use lexical-binding
* lisp/cedet/semantic/wisent/comp.el: lexical-binding. (wisent-defcontext): Make sure the vars are also dynbound in the files that `require` us. (wisent-state-actions, wisent-automaton-lisp-form): Use `obarray-make`. (wisent--compile-grammar): Rename from `wisent-compile-grammar`. (wisent-compile-grammar): Redefine as an obsolete function. (wisent-automaton-lisp-form): Avoid variable `state`. * lisp/cedet/semantic/grammar.el: Use lexical-binding. (semantic-grammar-require-form): New var. (semantic-grammar-header): Use it to provide new element `require-form`. (semantic-grammar-header-template): Use it. * lisp/cedet/semantic/wisent.el (wisent-compiled-grammar): New macro. * lisp/cedet/semantic/wisent/grammar.el (wisent-grammar-parsetable-builder): Use it in the generated code instead of the `wisent-compile-grammar` function. (wisent-grammar-mode): Set `semantic-grammar-require-form` so the generated ELisp files require `semantic/wisent` rather than `semantic/bovine`. * lisp/cedet/semantic/wisent/wisent.el: Use lexical-binding. * lisp/cedet/semantic/wisent/java-tags.el: Use lexical-binding. * lisp/cedet/semantic/wisent/python.el: Use lexical-binding. * lisp/cedet/semantic/wisent/javascript.el: Use lexical-binding. (semantic-ctxt-current-symbol): Remove unused var `symlist`. * admin/grammars/python.wy (wisent-python-EXPANDING-block): Declare dynbound var. * lisp/cedet/semantic/grammar-wy.el: Regenerate.
-rw-r--r--admin/grammars/grammar.wy10
-rw-r--r--admin/grammars/python.wy3
-rw-r--r--lisp/cedet/semantic/grammar-wy.el617
-rw-r--r--lisp/cedet/semantic/grammar.el60
-rw-r--r--lisp/cedet/semantic/wisent.el13
-rw-r--r--lisp/cedet/semantic/wisent/comp.el55
-rw-r--r--lisp/cedet/semantic/wisent/grammar.el12
-rw-r--r--lisp/cedet/semantic/wisent/java-tags.el4
-rw-r--r--lisp/cedet/semantic/wisent/javascript.el15
-rw-r--r--lisp/cedet/semantic/wisent/python.el8
-rw-r--r--lisp/cedet/semantic/wisent/wisent.el14
11 files changed, 417 insertions, 394 deletions
diff --git a/admin/grammars/grammar.wy b/admin/grammars/grammar.wy
index 054e85bf70d..35fb7e832e9 100644
--- a/admin/grammars/grammar.wy
+++ b/admin/grammars/grammar.wy
@@ -128,7 +128,7 @@ epilogue:
128;; 128;;
129declaration: 129declaration:
130 decl 130 decl
131 (eval $1) 131 (eval $1 t)
132 ; 132 ;
133 133
134decl: 134decl:
@@ -206,7 +206,7 @@ put_decl:
206 206
207put_name_list: 207put_name_list:
208 BRACE_BLOCK 208 BRACE_BLOCK
209 (mapcar 'semantic-tag-name (EXPANDFULL $1 put_names)) 209 (mapcar #'semantic-tag-name (EXPANDFULL $1 put_names))
210 ; 210 ;
211 211
212put_names: 212put_names:
@@ -226,7 +226,7 @@ put_name:
226 226
227put_value_list: 227put_value_list:
228 BRACE_BLOCK 228 BRACE_BLOCK
229 (mapcar 'semantic-tag-code-detail (EXPANDFULL $1 put_values)) 229 (mapcar #'semantic-tag-code-detail (EXPANDFULL $1 put_values))
230 ; 230 ;
231 231
232put_values: 232put_values:
@@ -300,7 +300,7 @@ plist:
300 300
301use_name_list: 301use_name_list:
302 BRACE_BLOCK 302 BRACE_BLOCK
303 (mapcar 'semantic-tag-name (EXPANDFULL $1 use_names)) 303 (mapcar #'semantic-tag-name (EXPANDFULL $1 use_names))
304 ; 304 ;
305 305
306use_names: 306use_names:
@@ -356,7 +356,7 @@ nonterminal:
356 356
357rules: 357rules:
358 lifo_rules 358 lifo_rules
359 (apply 'nconc (nreverse $1)) 359 (apply #'nconc (nreverse $1))
360 ; 360 ;
361 361
362lifo_rules: 362lifo_rules:
diff --git a/admin/grammars/python.wy b/admin/grammars/python.wy
index 9c8f4ac6a9c..22e85570dc1 100644
--- a/admin/grammars/python.wy
+++ b/admin/grammars/python.wy
@@ -97,6 +97,7 @@
97 (tag)) 97 (tag))
98(declare-function semantic-parse-region "semantic" 98(declare-function semantic-parse-region "semantic"
99 (start end &optional nonterminal depth returnonerror)) 99 (start end &optional nonterminal depth returnonerror))
100(defvar wisent-python-EXPANDING-block)
100} 101}
101 102
102%languagemode python-mode 103%languagemode python-mode
@@ -871,7 +872,7 @@ paren_class_list_opt
871paren_class_list 872paren_class_list
872 : PAREN_BLOCK 873 : PAREN_BLOCK
873 (let ((wisent-python-EXPANDING-block t)) 874 (let ((wisent-python-EXPANDING-block t))
874 (mapcar 'semantic-tag-name (EXPANDFULL $1 paren_classes))) 875 (mapcar #'semantic-tag-name (EXPANDFULL $1 paren_classes)))
875 ; 876 ;
876 877
877;; parameters: '(' [varargslist] ')' 878;; parameters: '(' [varargslist] ')'
diff --git a/lisp/cedet/semantic/grammar-wy.el b/lisp/cedet/semantic/grammar-wy.el
index 9a7f393072f..b3014034374 100644
--- a/lisp/cedet/semantic/grammar-wy.el
+++ b/lisp/cedet/semantic/grammar-wy.el
@@ -24,7 +24,7 @@
24;;; Code: 24;;; Code:
25 25
26(require 'semantic/lex) 26(require 'semantic/lex)
27(eval-when-compile (require 'semantic/bovine)) 27(require 'semantic/wisent)
28 28
29;;; Prologue 29;;; Prologue
30;; 30;;
@@ -112,315 +112,312 @@
112 "Table of lexical tokens.") 112 "Table of lexical tokens.")
113 113
114(defconst semantic-grammar-wy--parse-table 114(defconst semantic-grammar-wy--parse-table
115 (progn 115 (wisent-compiled-grammar
116 (eval-when-compile 116 ((DEFAULT-PREC NO-DEFAULT-PREC KEYWORD LANGUAGEMODE LEFT NONASSOC PACKAGE EXPECTEDCONFLICTS PROVIDE PREC PUT QUOTEMODE RIGHT SCOPESTART START TOKEN TYPE USE-MACROS STRING SYMBOL PERCENT_PERCENT CHARACTER PREFIXED_LIST SEXP PROLOGUE EPILOGUE PAREN_BLOCK BRACE_BLOCK LPAREN RPAREN LBRACE RBRACE COLON SEMI OR LT GT)
117 (require 'semantic/wisent/comp)) 117 nil
118 (wisent-compile-grammar 118 (grammar
119 '((DEFAULT-PREC NO-DEFAULT-PREC KEYWORD LANGUAGEMODE LEFT NONASSOC PACKAGE EXPECTEDCONFLICTS PROVIDE PREC PUT QUOTEMODE RIGHT SCOPESTART START TOKEN TYPE USE-MACROS STRING SYMBOL PERCENT_PERCENT CHARACTER PREFIXED_LIST SEXP PROLOGUE EPILOGUE PAREN_BLOCK BRACE_BLOCK LPAREN RPAREN LBRACE RBRACE COLON SEMI OR LT GT) 119 ((prologue))
120 nil 120 ((epilogue))
121 (grammar 121 ((declaration))
122 ((prologue)) 122 ((nonterminal))
123 ((epilogue)) 123 ((PERCENT_PERCENT)))
124 ((declaration)) 124 (prologue
125 ((nonterminal)) 125 ((PROLOGUE)
126 ((PERCENT_PERCENT))) 126 (wisent-raw-tag
127 (prologue 127 (semantic-tag-new-code "prologue" nil))))
128 ((PROLOGUE) 128 (epilogue
129 ((EPILOGUE)
130 (wisent-raw-tag
131 (semantic-tag-new-code "epilogue" nil))))
132 (declaration
133 ((decl)
134 (eval $1 t)))
135 (decl
136 ((default_prec_decl))
137 ((no_default_prec_decl))
138 ((languagemode_decl))
139 ((package_decl))
140 ((expectedconflicts_decl))
141 ((provide_decl))
142 ((precedence_decl))
143 ((put_decl))
144 ((quotemode_decl))
145 ((scopestart_decl))
146 ((start_decl))
147 ((keyword_decl))
148 ((token_decl))
149 ((type_decl))
150 ((use_macros_decl)))
151 (default_prec_decl
152 ((DEFAULT-PREC)
153 `(wisent-raw-tag
154 (semantic-tag "default-prec" 'assoc :value
155 '("t")))))
156 (no_default_prec_decl
157 ((NO-DEFAULT-PREC)
158 `(wisent-raw-tag
159 (semantic-tag "default-prec" 'assoc :value
160 '("nil")))))
161 (languagemode_decl
162 ((LANGUAGEMODE symbols)
163 `(wisent-raw-tag
164 (semantic-tag ',(car $2)
165 'languagemode :rest ',(cdr $2)))))
166 (package_decl
167 ((PACKAGE SYMBOL)
168 `(wisent-raw-tag
169 (semantic-tag-new-package ',$2 nil))))
170 (expectedconflicts_decl
171 ((EXPECTEDCONFLICTS symbols)
172 `(wisent-raw-tag
173 (semantic-tag ',(car $2)
174 'expectedconflicts :rest ',(cdr $2)))))
175 (provide_decl
176 ((PROVIDE SYMBOL)
177 `(wisent-raw-tag
178 (semantic-tag ',$2 'provide))))
179 (precedence_decl
180 ((associativity token_type_opt items)
181 `(wisent-raw-tag
182 (semantic-tag ',$1 'assoc :type ',$2 :value ',$3))))
183 (associativity
184 ((LEFT)
185 (progn "left"))
186 ((RIGHT)
187 (progn "right"))
188 ((NONASSOC)
189 (progn "nonassoc")))
190 (put_decl
191 ((PUT put_name put_value)
192 `(wisent-raw-tag
193 (semantic-tag ',$2 'put :value ',(list $3))))
194 ((PUT put_name put_value_list)
195 `(wisent-raw-tag
196 (semantic-tag ',$2 'put :value ',$3)))
197 ((PUT put_name_list put_value)
198 `(wisent-raw-tag
199 (semantic-tag ',(car $2)
200 'put :rest ',(cdr $2)
201 :value ',(list $3))))
202 ((PUT put_name_list put_value_list)
203 `(wisent-raw-tag
204 (semantic-tag ',(car $2)
205 'put :rest ',(cdr $2)
206 :value ',$3))))
207 (put_name_list
208 ((BRACE_BLOCK)
209 (mapcar #'semantic-tag-name
210 (semantic-parse-region
211 (car $region1)
212 (cdr $region1)
213 'put_names 1))))
214 (put_names
215 ((LBRACE)
216 nil)
217 ((RBRACE)
218 nil)
219 ((put_name)
220 (wisent-raw-tag
221 (semantic-tag $1 'put-name))))
222 (put_name
223 ((SYMBOL))
224 ((token_type)))
225 (put_value_list
226 ((BRACE_BLOCK)
227 (mapcar #'semantic-tag-code-detail
228 (semantic-parse-region
229 (car $region1)
230 (cdr $region1)
231 'put_values 1))))
232 (put_values
233 ((LBRACE)
234 nil)
235 ((RBRACE)
236 nil)
237 ((put_value)
238 (wisent-raw-tag
239 (semantic-tag-new-code "put-value" $1))))
240 (put_value
241 ((SYMBOL any_value)
242 (cons $1 $2)))
243 (scopestart_decl
244 ((SCOPESTART SYMBOL)
245 `(wisent-raw-tag
246 (semantic-tag ',$2 'scopestart))))
247 (quotemode_decl
248 ((QUOTEMODE SYMBOL)
249 `(wisent-raw-tag
250 (semantic-tag ',$2 'quotemode))))
251 (start_decl
252 ((START symbols)
253 `(wisent-raw-tag
254 (semantic-tag ',(car $2)
255 'start :rest ',(cdr $2)))))
256 (keyword_decl
257 ((KEYWORD SYMBOL string_value)
258 `(wisent-raw-tag
259 (semantic-tag ',$2 'keyword :value ',$3))))
260 (token_decl
261 ((TOKEN token_type_opt SYMBOL string_value)
262 `(wisent-raw-tag
263 (semantic-tag ',$3 ',(if $2 'token 'keyword)
264 :type ',$2 :value ',$4)))
265 ((TOKEN token_type_opt symbols)
266 `(wisent-raw-tag
267 (semantic-tag ',(car $3)
268 'token :type ',$2 :rest ',(cdr $3)))))
269 (token_type_opt
270 (nil)
271 ((token_type)))
272 (token_type
273 ((LT SYMBOL GT)
274 (progn $2)))
275 (type_decl
276 ((TYPE token_type plist_opt)
277 `(wisent-raw-tag
278 (semantic-tag ',$2 'type :value ',$3))))
279 (plist_opt
280 (nil)
281 ((plist)))
282 (plist
283 ((plist put_value)
284 (append
285 (list $2)
286 $1))
287 ((put_value)
288 (list $1)))
289 (use_name_list
290 ((BRACE_BLOCK)
291 (mapcar #'semantic-tag-name
292 (semantic-parse-region
293 (car $region1)
294 (cdr $region1)
295 'use_names 1))))
296 (use_names
297 ((LBRACE)
298 nil)
299 ((RBRACE)
300 nil)
301 ((SYMBOL)
302 (wisent-raw-tag
303 (semantic-tag $1 'use-name))))
304 (use_macros_decl
305 ((USE-MACROS SYMBOL use_name_list)
306 `(wisent-raw-tag
307 (semantic-tag "macro" 'macro :type ',$2 :value ',$3))))
308 (string_value
309 ((STRING)
310 (read $1)))
311 (any_value
312 ((SYMBOL))
313 ((STRING))
314 ((PAREN_BLOCK))
315 ((PREFIXED_LIST))
316 ((SEXP)))
317 (symbols
318 ((lifo_symbols)
319 (nreverse $1)))
320 (lifo_symbols
321 ((lifo_symbols SYMBOL)
322 (cons $2 $1))
323 ((SYMBOL)
324 (list $1)))
325 (nonterminal
326 ((SYMBOL
327 (setq semantic-grammar-wy--nterm $1 semantic-grammar-wy--rindx 0)
328 COLON rules SEMI)
329 (wisent-raw-tag
330 (semantic-tag $1 'nonterminal :children $4))))
331 (rules
332 ((lifo_rules)
333 (apply #'nconc
334 (nreverse $1))))
335 (lifo_rules
336 ((lifo_rules OR rule)
337 (cons $3 $1))
338 ((rule)
339 (list $1)))
340 (rule
341 ((rhs)
342 (let*
343 ((nterm semantic-grammar-wy--nterm)
344 (rindx semantic-grammar-wy--rindx)
345 (rhs $1)
346 comps prec action elt)
347 (setq semantic-grammar-wy--rindx
348 (1+ semantic-grammar-wy--rindx))
349 (while rhs
350 (setq elt
351 (car rhs)
352 rhs
353 (cdr rhs))
354 (cond
355 ((vectorp elt)
356 (if prec
357 (error "Duplicate %%prec in `%s:%d' rule" nterm rindx))
358 (setq prec
359 (aref elt 0)))
360 ((consp elt)
361 (if
362 (or action comps)
363 (setq comps
364 (cons elt comps)
365 semantic-grammar-wy--rindx
366 (1+ semantic-grammar-wy--rindx))
367 (setq action
368 (car elt))))
369 (t
370 (setq comps
371 (cons elt comps)))))
372 (wisent-cook-tag
129 (wisent-raw-tag 373 (wisent-raw-tag
130 (semantic-tag-new-code "prologue" nil)))) 374 (semantic-tag
131 (epilogue 375 (format "%s:%d" nterm rindx)
132 ((EPILOGUE) 376 'rule :type
133 (wisent-raw-tag 377 (if comps "group" "empty")
134 (semantic-tag-new-code "epilogue" nil)))) 378 :value comps :prec prec :expr action))))))
135 (declaration 379 (rhs
136 ((decl) 380 (nil)
137 (eval $1))) 381 ((rhs item)
138 (decl 382 (cons $2 $1))
139 ((default_prec_decl)) 383 ((rhs action)
140 ((no_default_prec_decl)) 384 (cons
141 ((languagemode_decl)) 385 (list $2)
142 ((package_decl)) 386 $1))
143 ((expectedconflicts_decl)) 387 ((rhs PREC item)
144 ((provide_decl)) 388 (cons
145 ((precedence_decl)) 389 (vector $3)
146 ((put_decl)) 390 $1)))
147 ((quotemode_decl)) 391 (action
148 ((scopestart_decl)) 392 ((PAREN_BLOCK))
149 ((start_decl)) 393 ((PREFIXED_LIST))
150 ((keyword_decl)) 394 ((BRACE_BLOCK)
151 ((token_decl)) 395 (format "(progn\n%s)"
152 ((type_decl)) 396 (let
153 ((use_macros_decl))) 397 ((s $1))
154 (default_prec_decl 398 (if
155 ((DEFAULT-PREC) 399 (string-match "^{[ \n ]*" s)
156 `(wisent-raw-tag 400 (setq s
157 (semantic-tag "default-prec" 'assoc :value 401 (substring s
158 '("t"))))) 402 (match-end 0))))
159 (no_default_prec_decl 403 (if
160 ((NO-DEFAULT-PREC) 404 (string-match "[ \n ]*}$" s)
161 `(wisent-raw-tag 405 (setq s
162 (semantic-tag "default-prec" 'assoc :value 406 (substring s 0
163 '("nil"))))) 407 (match-beginning 0))))
164 (languagemode_decl 408 s))))
165 ((LANGUAGEMODE symbols) 409 (items
166 `(wisent-raw-tag 410 ((lifo_items)
167 (semantic-tag ',(car $2) 411 (nreverse $1)))
168 'languagemode :rest ',(cdr $2))))) 412 (lifo_items
169 (package_decl 413 ((lifo_items item)
170 ((PACKAGE SYMBOL) 414 (cons $2 $1))
171 `(wisent-raw-tag 415 ((item)
172 (semantic-tag-new-package ',$2 nil)))) 416 (list $1)))
173 (expectedconflicts_decl 417 (item
174 ((EXPECTEDCONFLICTS symbols) 418 ((SYMBOL))
175 `(wisent-raw-tag 419 ((CHARACTER))))
176 (semantic-tag ',(car $2) 420 (grammar prologue epilogue declaration nonterminal rule put_names put_values use_names))
177 'expectedconflicts :rest ',(cdr $2)))))
178 (provide_decl
179 ((PROVIDE SYMBOL)
180 `(wisent-raw-tag
181 (semantic-tag ',$2 'provide))))
182 (precedence_decl
183 ((associativity token_type_opt items)
184 `(wisent-raw-tag
185 (semantic-tag ',$1 'assoc :type ',$2 :value ',$3))))
186 (associativity
187 ((LEFT)
188 (progn "left"))
189 ((RIGHT)
190 (progn "right"))
191 ((NONASSOC)
192 (progn "nonassoc")))
193 (put_decl
194 ((PUT put_name put_value)
195 `(wisent-raw-tag
196 (semantic-tag ',$2 'put :value ',(list $3))))
197 ((PUT put_name put_value_list)
198 `(wisent-raw-tag
199 (semantic-tag ',$2 'put :value ',$3)))
200 ((PUT put_name_list put_value)
201 `(wisent-raw-tag
202 (semantic-tag ',(car $2)
203 'put :rest ',(cdr $2)
204 :value ',(list $3))))
205 ((PUT put_name_list put_value_list)
206 `(wisent-raw-tag
207 (semantic-tag ',(car $2)
208 'put :rest ',(cdr $2)
209 :value ',$3))))
210 (put_name_list
211 ((BRACE_BLOCK)
212 (mapcar 'semantic-tag-name
213 (semantic-parse-region
214 (car $region1)
215 (cdr $region1)
216 'put_names 1))))
217 (put_names
218 ((LBRACE)
219 nil)
220 ((RBRACE)
221 nil)
222 ((put_name)
223 (wisent-raw-tag
224 (semantic-tag $1 'put-name))))
225 (put_name
226 ((SYMBOL))
227 ((token_type)))
228 (put_value_list
229 ((BRACE_BLOCK)
230 (mapcar 'semantic-tag-code-detail
231 (semantic-parse-region
232 (car $region1)
233 (cdr $region1)
234 'put_values 1))))
235 (put_values
236 ((LBRACE)
237 nil)
238 ((RBRACE)
239 nil)
240 ((put_value)
241 (wisent-raw-tag
242 (semantic-tag-new-code "put-value" $1))))
243 (put_value
244 ((SYMBOL any_value)
245 (cons $1 $2)))
246 (scopestart_decl
247 ((SCOPESTART SYMBOL)
248 `(wisent-raw-tag
249 (semantic-tag ',$2 'scopestart))))
250 (quotemode_decl
251 ((QUOTEMODE SYMBOL)
252 `(wisent-raw-tag
253 (semantic-tag ',$2 'quotemode))))
254 (start_decl
255 ((START symbols)
256 `(wisent-raw-tag
257 (semantic-tag ',(car $2)
258 'start :rest ',(cdr $2)))))
259 (keyword_decl
260 ((KEYWORD SYMBOL string_value)
261 `(wisent-raw-tag
262 (semantic-tag ',$2 'keyword :value ',$3))))
263 (token_decl
264 ((TOKEN token_type_opt SYMBOL string_value)
265 `(wisent-raw-tag
266 (semantic-tag ',$3 ',(if $2 'token 'keyword)
267 :type ',$2 :value ',$4)))
268 ((TOKEN token_type_opt symbols)
269 `(wisent-raw-tag
270 (semantic-tag ',(car $3)
271 'token :type ',$2 :rest ',(cdr $3)))))
272 (token_type_opt
273 (nil)
274 ((token_type)))
275 (token_type
276 ((LT SYMBOL GT)
277 (progn $2)))
278 (type_decl
279 ((TYPE token_type plist_opt)
280 `(wisent-raw-tag
281 (semantic-tag ',$2 'type :value ',$3))))
282 (plist_opt
283 (nil)
284 ((plist)))
285 (plist
286 ((plist put_value)
287 (append
288 (list $2)
289 $1))
290 ((put_value)
291 (list $1)))
292 (use_name_list
293 ((BRACE_BLOCK)
294 (mapcar 'semantic-tag-name
295 (semantic-parse-region
296 (car $region1)
297 (cdr $region1)
298 'use_names 1))))
299 (use_names
300 ((LBRACE)
301 nil)
302 ((RBRACE)
303 nil)
304 ((SYMBOL)
305 (wisent-raw-tag
306 (semantic-tag $1 'use-name))))
307 (use_macros_decl
308 ((USE-MACROS SYMBOL use_name_list)
309 `(wisent-raw-tag
310 (semantic-tag "macro" 'macro :type ',$2 :value ',$3))))
311 (string_value
312 ((STRING)
313 (read $1)))
314 (any_value
315 ((SYMBOL))
316 ((STRING))
317 ((PAREN_BLOCK))
318 ((PREFIXED_LIST))
319 ((SEXP)))
320 (symbols
321 ((lifo_symbols)
322 (nreverse $1)))
323 (lifo_symbols
324 ((lifo_symbols SYMBOL)
325 (cons $2 $1))
326 ((SYMBOL)
327 (list $1)))
328 (nonterminal
329 ((SYMBOL
330 (setq semantic-grammar-wy--nterm $1 semantic-grammar-wy--rindx 0)
331 COLON rules SEMI)
332 (wisent-raw-tag
333 (semantic-tag $1 'nonterminal :children $4))))
334 (rules
335 ((lifo_rules)
336 (apply 'nconc
337 (nreverse $1))))
338 (lifo_rules
339 ((lifo_rules OR rule)
340 (cons $3 $1))
341 ((rule)
342 (list $1)))
343 (rule
344 ((rhs)
345 (let*
346 ((nterm semantic-grammar-wy--nterm)
347 (rindx semantic-grammar-wy--rindx)
348 (rhs $1)
349 comps prec action elt)
350 (setq semantic-grammar-wy--rindx
351 (1+ semantic-grammar-wy--rindx))
352 (while rhs
353 (setq elt
354 (car rhs)
355 rhs
356 (cdr rhs))
357 (cond
358 ((vectorp elt)
359 (if prec
360 (error "Duplicate %%prec in `%s:%d' rule" nterm rindx))
361 (setq prec
362 (aref elt 0)))
363 ((consp elt)
364 (if
365 (or action comps)
366 (setq comps
367 (cons elt comps)
368 semantic-grammar-wy--rindx
369 (1+ semantic-grammar-wy--rindx))
370 (setq action
371 (car elt))))
372 (t
373 (setq comps
374 (cons elt comps)))))
375 (wisent-cook-tag
376 (wisent-raw-tag
377 (semantic-tag
378 (format "%s:%d" nterm rindx)
379 'rule :type
380 (if comps "group" "empty")
381 :value comps :prec prec :expr action))))))
382 (rhs
383 (nil)
384 ((rhs item)
385 (cons $2 $1))
386 ((rhs action)
387 (cons
388 (list $2)
389 $1))
390 ((rhs PREC item)
391 (cons
392 (vector $3)
393 $1)))
394 (action
395 ((PAREN_BLOCK))
396 ((PREFIXED_LIST))
397 ((BRACE_BLOCK)
398 (format "(progn\n%s)"
399 (let
400 ((s $1))
401 (if
402 (string-match "^{[ \n ]*" s)
403 (setq s
404 (substring s
405 (match-end 0))))
406 (if
407 (string-match "[ \n ]*}$" s)
408 (setq s
409 (substring s 0
410 (match-beginning 0))))
411 s))))
412 (items
413 ((lifo_items)
414 (nreverse $1)))
415 (lifo_items
416 ((lifo_items item)
417 (cons $2 $1))
418 ((item)
419 (list $1)))
420 (item
421 ((SYMBOL))
422 ((CHARACTER))))
423 '(grammar prologue epilogue declaration nonterminal rule put_names put_values use_names)))
424 "Parser table.") 421 "Parser table.")
425 422
426(defun semantic-grammar-wy--install-parser () 423(defun semantic-grammar-wy--install-parser ()
@@ -434,7 +431,7 @@
434 semantic-lex-types-obarray semantic-grammar-wy--token-table) 431 semantic-lex-types-obarray semantic-grammar-wy--token-table)
435 ;; Collect unmatched syntax lexical tokens 432 ;; Collect unmatched syntax lexical tokens
436 (add-hook 'wisent-discarding-token-functions 433 (add-hook 'wisent-discarding-token-functions
437 'wisent-collect-unmatched-syntax nil t)) 434 #'wisent-collect-unmatched-syntax nil t))
438 435
439 436
440;;; Analyzers 437;;; Analyzers
diff --git a/lisp/cedet/semantic/grammar.el b/lisp/cedet/semantic/grammar.el
index 4551811c235..ca7c273febc 100644
--- a/lisp/cedet/semantic/grammar.el
+++ b/lisp/cedet/semantic/grammar.el
@@ -1,4 +1,4 @@
1;;; semantic/grammar.el --- Major mode framework for Semantic grammars 1;;; semantic/grammar.el --- Major mode framework for Semantic grammars -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2002-2005, 2007-2021 Free Software Foundation, Inc. 3;; Copyright (C) 2002-2005, 2007-2021 Free Software Foundation, Inc.
4 4
@@ -191,11 +191,11 @@ Warn if other tags of class CLASS exist."
191That is tag names plus names defined in tag attribute `:rest'." 191That is tag names plus names defined in tag attribute `:rest'."
192 (let* ((tags (semantic-find-tags-by-class 192 (let* ((tags (semantic-find-tags-by-class
193 class (current-buffer)))) 193 class (current-buffer))))
194 (apply 'append 194 (apply #'append
195 (mapcar 195 (mapcar
196 #'(lambda (tag) 196 #'(lambda (tag)
197 (mapcar 197 (mapcar
198 'intern 198 #'intern
199 (cons (semantic-tag-name tag) 199 (cons (semantic-tag-name tag)
200 (semantic-tag-get-attribute tag :rest)))) 200 (semantic-tag-get-attribute tag :rest))))
201 tags)))) 201 tags))))
@@ -312,7 +312,7 @@ the keyword and TOKEN is the terminal symbol identifying the keyword."
312 (setq put (car puts) 312 (setq put (car puts)
313 puts (cdr puts) 313 puts (cdr puts)
314 keys (mapcar 314 keys (mapcar
315 'intern 315 #'intern
316 (cons (semantic-tag-name put) 316 (cons (semantic-tag-name put)
317 (semantic-tag-get-attribute put :rest)))) 317 (semantic-tag-get-attribute put :rest))))
318 (while keys 318 (while keys
@@ -565,6 +565,10 @@ Typically a DEFINE expression should look like this:
565 (goto-char start) 565 (goto-char start)
566 (indent-sexp)))) 566 (indent-sexp))))
567 567
568(defvar semantic-grammar-require-form
569 '(eval-when-compile (require 'semantic/bovine))
570 "The form to use to load the parser engine.")
571
568(defconst semantic-grammar-header-template 572(defconst semantic-grammar-header-template
569 '("\ 573 '("\
570;;; " file " --- Generated parser support file 574;;; " file " --- Generated parser support file
@@ -602,7 +606,7 @@ Typically a DEFINE expression should look like this:
602;;; Code: 606;;; Code:
603 607
604(require 'semantic/lex) 608(require 'semantic/lex)
605(eval-when-compile (require 'semantic/bovine)) 609" require-form "
606") 610")
607 "Generated header template. 611 "Generated header template.
608The symbols in the template are local variables in 612The symbols in the template are local variables in
@@ -651,6 +655,7 @@ The symbols in the list are local variables in
651 semantic--grammar-output-buffer)) 655 semantic--grammar-output-buffer))
652 (gram . ,(semantic-grammar-buffer-file)) 656 (gram . ,(semantic-grammar-buffer-file))
653 (date . ,(format-time-string "%Y-%m-%d %T%z")) 657 (date . ,(format-time-string "%Y-%m-%d %T%z"))
658 (require-form . ,(format "%S" semantic-grammar-require-form))
654 (vcid . ,(concat "$" "Id" "$")) ;; Avoid expansion 659 (vcid . ,(concat "$" "Id" "$")) ;; Avoid expansion
655 ;; Try to get the copyright from the input grammar, or 660 ;; Try to get the copyright from the input grammar, or
656 ;; generate a new one if not found. 661 ;; generate a new one if not found.
@@ -818,7 +823,7 @@ Block definitions are read from the current table of lexical types."
818 (let ((semantic-lex-types-obarray 823 (let ((semantic-lex-types-obarray
819 (semantic-lex-make-type-table tokens props)) 824 (semantic-lex-make-type-table tokens props))
820 semantic-grammar--lex-block-specs) 825 semantic-grammar--lex-block-specs)
821 (mapatoms 'semantic-grammar-insert-defanalyzer 826 (mapatoms #'semantic-grammar-insert-defanalyzer
822 semantic-lex-types-obarray)))) 827 semantic-lex-types-obarray))))
823 828
824;;; Generation of the grammar support file. 829;;; Generation of the grammar support file.
@@ -846,7 +851,8 @@ Lisp code."
846 (semantic--grammar-package (semantic-grammar-package)) 851 (semantic--grammar-package (semantic-grammar-package))
847 (semantic--grammar-provide (semantic-grammar-first-tag-name 'provide)) 852 (semantic--grammar-provide (semantic-grammar-first-tag-name 'provide))
848 (output (concat (or semantic--grammar-provide 853 (output (concat (or semantic--grammar-provide
849 semantic--grammar-package) ".el")) 854 semantic--grammar-package)
855 ".el"))
850 (semantic--grammar-input-buffer (current-buffer)) 856 (semantic--grammar-input-buffer (current-buffer))
851 (semantic--grammar-output-buffer 857 (semantic--grammar-output-buffer
852 (find-file-noselect 858 (find-file-noselect
@@ -1197,20 +1203,20 @@ END is the limit of the search."
1197(defvar semantic-grammar-mode-map 1203(defvar semantic-grammar-mode-map
1198 (let ((km (make-sparse-keymap))) 1204 (let ((km (make-sparse-keymap)))
1199 1205
1200 (define-key km "|" 'semantic-grammar-electric-punctuation) 1206 (define-key km "|" #'semantic-grammar-electric-punctuation)
1201 (define-key km ";" 'semantic-grammar-electric-punctuation) 1207 (define-key km ";" #'semantic-grammar-electric-punctuation)
1202 (define-key km "%" 'semantic-grammar-electric-punctuation) 1208 (define-key km "%" #'semantic-grammar-electric-punctuation)
1203 (define-key km "(" 'semantic-grammar-electric-punctuation) 1209 (define-key km "(" #'semantic-grammar-electric-punctuation)
1204 (define-key km ")" 'semantic-grammar-electric-punctuation) 1210 (define-key km ")" #'semantic-grammar-electric-punctuation)
1205 (define-key km ":" 'semantic-grammar-electric-punctuation) 1211 (define-key km ":" #'semantic-grammar-electric-punctuation)
1206 1212
1207 (define-key km "\t" 'semantic-grammar-indent) 1213 (define-key km "\t" #'semantic-grammar-indent)
1208 (define-key km "\M-\t" 'semantic-grammar-complete) 1214 (define-key km "\M-\t" #'semantic-grammar-complete)
1209 (define-key km "\C-c\C-c" 'semantic-grammar-create-package) 1215 (define-key km "\C-c\C-c" #'semantic-grammar-create-package)
1210 (define-key km "\C-cm" 'semantic-grammar-find-macro-expander) 1216 (define-key km "\C-cm" #'semantic-grammar-find-macro-expander)
1211 (define-key km "\C-cik" 'semantic-grammar-insert-keyword) 1217 (define-key km "\C-cik" #'semantic-grammar-insert-keyword)
1212;; (define-key km "\C-cc" 'semantic-grammar-generate-and-load) 1218;; (define-key km "\C-cc" #'semantic-grammar-generate-and-load)
1213;; (define-key km "\C-cr" 'semantic-grammar-generate-one-rule) 1219;; (define-key km "\C-cr" #'semantic-grammar-generate-one-rule)
1214 1220
1215 km) 1221 km)
1216 "Keymap used in `semantic-grammar-mode'.") 1222 "Keymap used in `semantic-grammar-mode'.")
@@ -1322,7 +1328,7 @@ the change bounds to encompass the whole nonterminal tag."
1322 ;; Setup Semantic to parse grammar 1328 ;; Setup Semantic to parse grammar
1323 (semantic-grammar-wy--install-parser) 1329 (semantic-grammar-wy--install-parser)
1324 (setq semantic-lex-comment-regex ";;" 1330 (setq semantic-lex-comment-regex ";;"
1325 semantic-lex-analyzer 'semantic-grammar-lexer 1331 semantic-lex-analyzer #'semantic-grammar-lexer
1326 semantic-type-relation-separator-character '(":") 1332 semantic-type-relation-separator-character '(":")
1327 semantic-symbol->name-assoc-list 1333 semantic-symbol->name-assoc-list
1328 '( 1334 '(
@@ -1343,10 +1349,10 @@ the change bounds to encompass the whole nonterminal tag."
1343 ;; Before each change, clear the cached regexp used to highlight 1349 ;; Before each change, clear the cached regexp used to highlight
1344 ;; macros local in this grammar. 1350 ;; macros local in this grammar.
1345 (add-hook 'before-change-functions 1351 (add-hook 'before-change-functions
1346 'semantic--grammar-clear-macros-regexp-2 nil t) 1352 #'semantic--grammar-clear-macros-regexp-2 nil t)
1347 ;; Handle safe re-parse of grammar rules. 1353 ;; Handle safe re-parse of grammar rules.
1348 (add-hook 'semantic-edits-new-change-functions 1354 (add-hook 'semantic-edits-new-change-functions
1349 'semantic-grammar-edits-new-change-hook-fcn 1355 #'semantic-grammar-edits-new-change-hook-fcn
1350 nil t)) 1356 nil t))
1351 1357
1352;;;; 1358;;;;
@@ -1876,7 +1882,7 @@ Optional argument COLOR determines if color is added to the text."
1876 (names (semantic-tag-get-attribute tag :rest)) 1882 (names (semantic-tag-get-attribute tag :rest))
1877 (type (semantic-tag-type tag))) 1883 (type (semantic-tag-type tag)))
1878 (if names 1884 (if names
1879 (setq name (mapconcat 'identity (cons name names) " "))) 1885 (setq name (mapconcat #'identity (cons name names) " ")))
1880 (setq desc (concat 1886 (setq desc (concat
1881 (if type 1887 (if type
1882 (format " <%s>" type) 1888 (format " <%s>" type)
@@ -1893,7 +1899,7 @@ Optional argument COLOR determines if color is added to the text."
1893 (format " <%s>" type) 1899 (format " <%s>" type)
1894 "") 1900 "")
1895 (if val 1901 (if val
1896 (concat " " (mapconcat 'identity val " ")) 1902 (concat " " (mapconcat #'identity val " "))
1897 ""))))) 1903 "")))))
1898 (t 1904 (t
1899 (setq desc (semantic-format-tag-abbreviate tag parent color)))) 1905 (setq desc (semantic-format-tag-abbreviate tag parent color))))
@@ -1944,7 +1950,7 @@ Optional argument COLOR determines if color is added to the text."
1944 context-return))) 1950 context-return)))
1945 1951
1946(define-mode-local-override semantic-analyze-possible-completions 1952(define-mode-local-override semantic-analyze-possible-completions
1947 semantic-grammar-mode (context &rest flags) 1953 semantic-grammar-mode (context &rest _flags)
1948 "Return a list of possible completions based on CONTEXT." 1954 "Return a list of possible completions based on CONTEXT."
1949 (require 'semantic/analyze/complete) 1955 (require 'semantic/analyze/complete)
1950 (if (semantic-grammar-in-lisp-p) 1956 (if (semantic-grammar-in-lisp-p)
diff --git a/lisp/cedet/semantic/wisent.el b/lisp/cedet/semantic/wisent.el
index ecd96831352..f498e7edcc2 100644
--- a/lisp/cedet/semantic/wisent.el
+++ b/lisp/cedet/semantic/wisent.el
@@ -224,7 +224,7 @@ the standard function `semantic-parse-stream'."
224 (error-message-string error-to-filter)) 224 (error-message-string error-to-filter))
225 (message "wisent-parse-max-stack-size \ 225 (message "wisent-parse-max-stack-size \
226might need to be increased")) 226might need to be increased"))
227 (apply 'signal error-to-filter)))))) 227 (apply #'signal error-to-filter))))))
228 ;; Manage returned lookahead token 228 ;; Manage returned lookahead token
229 (if wisent-lookahead 229 (if wisent-lookahead
230 (if (eq (caar la-elt) wisent-lookahead) 230 (if (eq (caar la-elt) wisent-lookahead)
@@ -252,6 +252,17 @@ might need to be increased"))
252 (if (consp cache) cache '(nil)) 252 (if (consp cache) cache '(nil))
253 ))) 253 )))
254 254
255(defmacro wisent-compiled-grammar (grammar &optional start-list)
256 "Return a compiled form of the LALR(1) Wisent GRAMMAR.
257See `wisent--compile-grammar' for a description of the arguments
258and return value."
259 ;; Ensure that the grammar compiler is available.
260 (require 'semantic/wisent/comp)
261 (declare-function wisent-automaton-lisp-form "semantic/wisent/comp" (x))
262 (declare-function wisent--compile-grammar "semantic/wisent/comp" (grm st))
263 (wisent-automaton-lisp-form
264 (wisent--compile-grammar grammar start-list)))
265
255(defun wisent-parse-region (start end &optional goal depth returnonerror) 266(defun wisent-parse-region (start end &optional goal depth returnonerror)
256 "Parse the area between START and END using the Wisent LALR parser. 267 "Parse the area between START and END using the Wisent LALR parser.
257Return the list of semantic tags found. 268Return the list of semantic tags found.
diff --git a/lisp/cedet/semantic/wisent/comp.el b/lisp/cedet/semantic/wisent/comp.el
index 7a64fe2fec3..574922049f5 100644
--- a/lisp/cedet/semantic/wisent/comp.el
+++ b/lisp/cedet/semantic/wisent/comp.el
@@ -1,4 +1,4 @@
1;;; semantic/wisent/comp.el --- GNU Bison for Emacs - Grammar compiler 1;;; semantic/wisent/comp.el --- GNU Bison for Emacs - Grammar compiler -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000-2007, 2009-2021 Free 3;; Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000-2007, 2009-2021 Free
4;; Software Foundation, Inc. 4;; Software Foundation, Inc.
@@ -71,7 +71,7 @@
71 (declarations (mapcar #'(lambda (v) (list 'defvar v)) vars))) 71 (declarations (mapcar #'(lambda (v) (list 'defvar v)) vars)))
72 `(progn 72 `(progn
73 ,@declarations 73 ,@declarations
74 (eval-when-compile 74 (eval-and-compile
75 (defvar ,context ',vars))))) 75 (defvar ,context ',vars)))))
76 76
77(defmacro wisent-with-context (name &rest body) 77(defmacro wisent-with-context (name &rest body)
@@ -101,6 +101,8 @@ If optional LEFT is non-nil insert spaces on left."
101;;;; Environment dependencies 101;;;; Environment dependencies
102;;;; ------------------------ 102;;;; ------------------------
103 103
104;; FIXME: Use bignums or bool-vectors?
105
104(defconst wisent-BITS-PER-WORD (logcount most-positive-fixnum)) 106(defconst wisent-BITS-PER-WORD (logcount most-positive-fixnum))
105 107
106(defsubst wisent-WORDSIZE (n) 108(defsubst wisent-WORDSIZE (n)
@@ -2774,7 +2776,7 @@ that likes a token gets to handle it."
2774 "Figure out the actions for every state. 2776 "Figure out the actions for every state.
2775Return the action table." 2777Return the action table."
2776 ;; Store the semantic action obarray in (unused) RCODE[0]. 2778 ;; Store the semantic action obarray in (unused) RCODE[0].
2777 (aset rcode 0 (make-vector 13 0)) 2779 (aset rcode 0 (obarray-make 13))
2778 (let (i j action-table actrow action) 2780 (let (i j action-table actrow action)
2779 (setq action-table (make-vector nstates nil) 2781 (setq action-table (make-vector nstates nil)
2780 actrow (make-vector ntokens nil) 2782 actrow (make-vector ntokens nil)
@@ -3388,7 +3390,7 @@ NONTERMS is the list of non terminal definitions (see function
3388;;;; Compile input grammar 3390;;;; Compile input grammar
3389;;;; --------------------- 3391;;;; ---------------------
3390 3392
3391(defun wisent-compile-grammar (grammar &optional start-list) 3393(defun wisent--compile-grammar (grammar start-list)
3392 "Compile the LALR(1) GRAMMAR. 3394 "Compile the LALR(1) GRAMMAR.
3393 3395
3394GRAMMAR is a list (TOKENS ASSOCS . NONTERMS) where: 3396GRAMMAR is a list (TOKENS ASSOCS . NONTERMS) where:
@@ -3440,7 +3442,7 @@ where:
3440 (wisent-parser-automaton))))) 3442 (wisent-parser-automaton)))))
3441 3443
3442;;;; -------------------------- 3444;;;; --------------------------
3443;;;; Byte compile input grammar 3445;;;; Obsolete byte compile support
3444;;;; -------------------------- 3446;;;; --------------------------
3445 3447
3446(require 'bytecomp) 3448(require 'bytecomp)
@@ -3449,25 +3451,32 @@ where:
3449 "Byte compile the `wisent-compile-grammar' FORM. 3451 "Byte compile the `wisent-compile-grammar' FORM.
3450Automatically called by the Emacs Lisp byte compiler as a 3452Automatically called by the Emacs Lisp byte compiler as a
3451`byte-compile' handler." 3453`byte-compile' handler."
3452 ;; Eval the `wisent-compile-grammar' form to obtain an LALR
3453 ;; automaton internal data structure. Then, because the internal
3454 ;; data structure contains an obarray, convert it to a lisp form so
3455 ;; it can be byte-compiled.
3456 (byte-compile-form 3454 (byte-compile-form
3457 ;; FIXME: we macroexpand here since `byte-compile-form' expects
3458 ;; macroexpanded code, but that's just a workaround: for lexical-binding
3459 ;; the lisp form should have to pass through closure-conversion and
3460 ;; `wisent-byte-compile-grammar' is called much too late for that.
3461 ;; Why isn't this `wisent-automaton-lisp-form' performed at
3462 ;; macroexpansion time? --Stef
3463 (macroexpand-all 3455 (macroexpand-all
3464 (wisent-automaton-lisp-form (eval form))))) 3456 (wisent-automaton-lisp-form (eval form)))))
3465 3457
3466;; FIXME: We shouldn't use a `byte-compile' handler. Maybe using a hash-table 3458(defun wisent-compile-grammar (grammar &optional start-list)
3467;; instead of an obarray would work around the problem that obarrays 3459 ;; This is kept for compatibility with FOO-wy.el files generated
3468;; aren't printable. Then (put 'wisent-compile-grammar 'side-effect-free t). 3460 ;; with older Emacsen.
3469(put 'wisent-compile-grammar 'byte-compile 'wisent-byte-compile-grammar) 3461 (declare (obsolete wisent-compiled-grammar "Mar 2021"))
3462 (wisent--compile-grammar grammar start-list))
3463
3464(put 'wisent-compile-grammar 'byte-compile #'wisent-byte-compile-grammar)
3465
3466;;;; --------------------------
3467;;;; Byte compile input grammar
3468;;;; --------------------------
3470 3469
3470;; `wisent--compile-grammar' generates the actual parse table
3471;; we need at run-time, but in order to be able to compile the code it
3472;; contains, we need to "reify" it back into a piece of ELisp code
3473;; which (re)builds it.
3474;; This is needed for 2 reasons:
3475;; - The parse tables include an obarray and these don't survive the print+read
3476;; steps involved in generating a `.elc' file and reading it back in.
3477;; - Within the parse table vectors/obarrays we have ELisp functions which
3478;; we want to byte-compile, but if we were to just `quote' the table
3479;; we'd get them with the same non-compiled functions.
3471(defun wisent-automaton-lisp-form (automaton) 3480(defun wisent-automaton-lisp-form (automaton)
3472 "Return a Lisp form that produces AUTOMATON. 3481 "Return a Lisp form that produces AUTOMATON.
3473See also `wisent-compile-grammar' for more details on AUTOMATON." 3482See also `wisent-compile-grammar' for more details on AUTOMATON."
@@ -3477,7 +3486,7 @@ See also `wisent-compile-grammar' for more details on AUTOMATON."
3477 (let ((obn (make-symbol "ob")) ; Generated obarray name 3486 (let ((obn (make-symbol "ob")) ; Generated obarray name
3478 (obv (aref automaton 3)) ; Semantic actions obarray 3487 (obv (aref automaton 3)) ; Semantic actions obarray
3479 ) 3488 )
3480 `(let ((,obn (make-vector 13 0))) 3489 `(let ((,obn (obarray-make 13)))
3481 ;; Generate code to initialize the semantic actions obarray, 3490 ;; Generate code to initialize the semantic actions obarray,
3482 ;; in local variable OBN. 3491 ;; in local variable OBN.
3483 ,@(let (obcode) 3492 ,@(let (obcode)
@@ -3496,7 +3505,9 @@ See also `wisent-compile-grammar' for more details on AUTOMATON."
3496 ;; obarray. 3505 ;; obarray.
3497 (vector 3506 (vector
3498 ,@(mapcar 3507 ,@(mapcar
3499 #'(lambda (state) ;; for each state 3508 ;; Use name `st' rather than `state' since `state' is
3509 ;; defined as dynbound in `semantic-actions' context above :-( !
3510 #'(lambda (st) ;; for each state
3500 `(list 3511 `(list
3501 ,@(mapcar 3512 ,@(mapcar
3502 #'(lambda (tr) ;; for each transition 3513 #'(lambda (tr) ;; for each transition
@@ -3507,7 +3518,7 @@ See also `wisent-compile-grammar' for more details on AUTOMATON."
3507 `(cons ,(if (symbolp k) `(quote ,k) k) 3518 `(cons ,(if (symbolp k) `(quote ,k) k)
3508 (intern-soft ,(symbol-name a) ,obn)) 3519 (intern-soft ,(symbol-name a) ,obn))
3509 `(quote ,tr)))) 3520 `(quote ,tr))))
3510 state))) 3521 st)))
3511 (aref automaton 0))) 3522 (aref automaton 0)))
3512 ;; The code of the goto table is unchanged. 3523 ;; The code of the goto table is unchanged.
3513 ,(aref automaton 1) 3524 ,(aref automaton 1)
diff --git a/lisp/cedet/semantic/wisent/grammar.el b/lisp/cedet/semantic/wisent/grammar.el
index edc5c5c7029..819ebd5dad5 100644
--- a/lisp/cedet/semantic/wisent/grammar.el
+++ b/lisp/cedet/semantic/wisent/grammar.el
@@ -286,12 +286,9 @@ Return the expanded expression."
286 286
287(defun wisent-grammar-parsetable-builder () 287(defun wisent-grammar-parsetable-builder ()
288 "Return the value of the parser table." 288 "Return the value of the parser table."
289 `(progn 289 `(wisent-compiled-grammar
290 ;; Ensure that the grammar [byte-]compiler is available. 290 ,(wisent-grammar-grammar)
291 (eval-when-compile (require 'semantic/wisent/comp)) 291 ,(semantic-grammar-start)))
292 (wisent-compile-grammar
293 ',(wisent-grammar-grammar)
294 ',(semantic-grammar-start))))
295 292
296(defun wisent-grammar-setupcode-builder () 293(defun wisent-grammar-setupcode-builder ()
297 "Return the parser setup code." 294 "Return the parser setup code."
@@ -305,7 +302,7 @@ Return the expanded expression."
305 semantic-lex-types-obarray %s)\n\ 302 semantic-lex-types-obarray %s)\n\
306 ;; Collect unmatched syntax lexical tokens\n\ 303 ;; Collect unmatched syntax lexical tokens\n\
307 (add-hook 'wisent-discarding-token-functions\n\ 304 (add-hook 'wisent-discarding-token-functions\n\
308 'wisent-collect-unmatched-syntax nil t)" 305 #'wisent-collect-unmatched-syntax nil t)"
309 (semantic-grammar-parsetable) 306 (semantic-grammar-parsetable)
310 (buffer-name) 307 (buffer-name)
311 (semantic-grammar-keywordtable) 308 (semantic-grammar-keywordtable)
@@ -325,6 +322,7 @@ Menu items are appended to the common grammar menu.")
325(define-derived-mode wisent-grammar-mode semantic-grammar-mode "WY" 322(define-derived-mode wisent-grammar-mode semantic-grammar-mode "WY"
326 "Major mode for editing Wisent grammars." 323 "Major mode for editing Wisent grammars."
327 (semantic-grammar-setup-menu wisent-grammar-menu) 324 (semantic-grammar-setup-menu wisent-grammar-menu)
325 (setq-local semantic-grammar-require-form '(require 'semantic/wisent))
328 (semantic-install-function-overrides 326 (semantic-install-function-overrides
329 '((semantic-grammar-parsetable-builder . wisent-grammar-parsetable-builder) 327 '((semantic-grammar-parsetable-builder . wisent-grammar-parsetable-builder)
330 (semantic-grammar-setupcode-builder . wisent-grammar-setupcode-builder)))) 328 (semantic-grammar-setupcode-builder . wisent-grammar-setupcode-builder))))
diff --git a/lisp/cedet/semantic/wisent/java-tags.el b/lisp/cedet/semantic/wisent/java-tags.el
index d455c02d1b5..adb9a30894e 100644
--- a/lisp/cedet/semantic/wisent/java-tags.el
+++ b/lisp/cedet/semantic/wisent/java-tags.el
@@ -1,4 +1,4 @@
1;;; semantic/wisent/java-tags.el --- Java LALR parser for Emacs 1;;; semantic/wisent/java-tags.el --- Java LALR parser for Emacs -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2001-2006, 2009-2021 Free Software Foundation, Inc. 3;; Copyright (C) 2001-2006, 2009-2021 Free Software Foundation, Inc.
4 4
@@ -92,7 +92,7 @@ This function override `get-local-variables'."
92 92
93(define-mode-local-override semantic-analyze-unsplit-name java-mode (namelist) 93(define-mode-local-override semantic-analyze-unsplit-name java-mode (namelist)
94 "Assemble the list of names NAMELIST into a namespace name." 94 "Assemble the list of names NAMELIST into a namespace name."
95 (mapconcat 'identity namelist ".")) 95 (mapconcat #'identity namelist "."))
96 96
97 97
98 98
diff --git a/lisp/cedet/semantic/wisent/javascript.el b/lisp/cedet/semantic/wisent/javascript.el
index 684eea1d93d..9db51ad36b6 100644
--- a/lisp/cedet/semantic/wisent/javascript.el
+++ b/lisp/cedet/semantic/wisent/javascript.el
@@ -1,4 +1,4 @@
1;;; semantic/wisent/javascript.el --- javascript parser support 1;;; semantic/wisent/javascript.el --- javascript parser support -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2005, 2009-2021 Free Software Foundation, Inc. 3;; Copyright (C) 2005, 2009-2021 Free Software Foundation, Inc.
4 4
@@ -70,7 +70,7 @@ This function overrides `get-local-variables'."
70 ;; Does javascript have identifiable local variables? 70 ;; Does javascript have identifiable local variables?
71 nil) 71 nil)
72 72
73(define-mode-local-override semantic-tag-protection js-mode (tag &optional parent) 73(define-mode-local-override semantic-tag-protection js-mode (_tag &optional _parent)
74 "Return protection information about TAG with optional PARENT. 74 "Return protection information about TAG with optional PARENT.
75This function returns on of the following symbols: 75This function returns on of the following symbols:
76 nil - No special protection. Language dependent. 76 nil - No special protection. Language dependent.
@@ -85,7 +85,7 @@ The default behavior (if not overridden with `tag-protection'
85is to return a symbol based on type modifiers." 85is to return a symbol based on type modifiers."
86 nil) 86 nil)
87 87
88(define-mode-local-override semantic-analyze-scope-calculate-access js-mode (type scope) 88(define-mode-local-override semantic-analyze-scope-calculate-access js-mode (_type _scope)
89 "Calculate the access class for TYPE as defined by the current SCOPE. 89 "Calculate the access class for TYPE as defined by the current SCOPE.
90Access is related to the :parents in SCOPE. If type is a member of SCOPE 90Access is related to the :parents in SCOPE. If type is a member of SCOPE
91then access would be `private'. If TYPE is inherited by a member of SCOPE, 91then access would be `private'. If TYPE is inherited by a member of SCOPE,
@@ -101,7 +101,7 @@ This is currently needed for the mozrepl omniscient database."
101 (save-excursion 101 (save-excursion
102 (if point (goto-char point)) 102 (if point (goto-char point))
103 (let* ((case-fold-search semantic-case-fold) 103 (let* ((case-fold-search semantic-case-fold)
104 symlist tmp end) 104 tmp end) ;; symlist
105 (with-syntax-table semantic-lex-syntax-table 105 (with-syntax-table semantic-lex-syntax-table
106 (save-excursion 106 (save-excursion
107 (when (looking-at "\\w\\|\\s_") 107 (when (looking-at "\\w\\|\\s_")
@@ -110,10 +110,11 @@ This is currently needed for the mozrepl omniscient database."
110 (unless (re-search-backward "\\s-" (point-at-bol) t) 110 (unless (re-search-backward "\\s-" (point-at-bol) t)
111 (beginning-of-line)) 111 (beginning-of-line))
112 (setq tmp (buffer-substring-no-properties (point) end)) 112 (setq tmp (buffer-substring-no-properties (point) end))
113 ;; (setq symlist
113 (if (string-match "\\(.+\\)\\." tmp) 114 (if (string-match "\\(.+\\)\\." tmp)
114 (setq symlist (list (match-string 1 tmp) 115 (list (match-string 1 tmp)
115 (substring tmp (1+ (match-end 1)) (length tmp)))) 116 (substring tmp (1+ (match-end 1)) (length tmp)))
116 (setq symlist (list tmp)))))))) 117 (list tmp)))))));; )
117 118
118;;; Setup Function 119;;; Setup Function
119;; 120;;
diff --git a/lisp/cedet/semantic/wisent/python.el b/lisp/cedet/semantic/wisent/python.el
index 7769ad1961b..8732b2e975c 100644
--- a/lisp/cedet/semantic/wisent/python.el
+++ b/lisp/cedet/semantic/wisent/python.el
@@ -1,4 +1,4 @@
1;;; wisent-python.el --- Semantic support for Python 1;;; wisent-python.el --- Semantic support for Python -*- lexical-binding: t; -*-
2 2
3;; Copyright (C) 2002, 2004, 2006-2021 Free Software Foundation, Inc. 3;; Copyright (C) 2002, 2004, 2006-2021 Free Software Foundation, Inc.
4 4
@@ -464,19 +464,19 @@ To be implemented for Python! For now just return nil."
464(define-mode-local-override semantic-tag-include-filename python-mode (tag) 464(define-mode-local-override semantic-tag-include-filename python-mode (tag)
465 "Return a suitable path for (some) Python imports." 465 "Return a suitable path for (some) Python imports."
466 (let ((name (semantic-tag-name tag))) 466 (let ((name (semantic-tag-name tag)))
467 (concat (mapconcat 'identity (split-string name "\\.") "/") ".py"))) 467 (concat (mapconcat #'identity (split-string name "\\.") "/") ".py")))
468 468
469;; Override ctxt-current-function/assignment defaults, since they do 469;; Override ctxt-current-function/assignment defaults, since they do
470;; not work properly with Python code, even leading to endless loops 470;; not work properly with Python code, even leading to endless loops
471;; (see bug #xxxxx). 471;; (see bug #xxxxx).
472(define-mode-local-override semantic-ctxt-current-function python-mode (&optional point) 472(define-mode-local-override semantic-ctxt-current-function python-mode (&optional _point)
473 "Return the current function call the cursor is in at POINT. 473 "Return the current function call the cursor is in at POINT.
474The function returned is the one accepting the arguments that 474The function returned is the one accepting the arguments that
475the cursor is currently in. It will not return function symbol if the 475the cursor is currently in. It will not return function symbol if the
476cursor is on the text representing that function." 476cursor is on the text representing that function."
477 nil) 477 nil)
478 478
479(define-mode-local-override semantic-ctxt-current-assignment python-mode (&optional point) 479(define-mode-local-override semantic-ctxt-current-assignment python-mode (&optional _point)
480 "Return the current assignment near the cursor at POINT. 480 "Return the current assignment near the cursor at POINT.
481Return a list as per `semantic-ctxt-current-symbol'. 481Return a list as per `semantic-ctxt-current-symbol'.
482Return nil if there is nothing relevant." 482Return nil if there is nothing relevant."
diff --git a/lisp/cedet/semantic/wisent/wisent.el b/lisp/cedet/semantic/wisent/wisent.el
index 26cf87f8425..df1fd73e29e 100644
--- a/lisp/cedet/semantic/wisent/wisent.el
+++ b/lisp/cedet/semantic/wisent/wisent.el
@@ -1,4 +1,4 @@
1;;; semantic/wisent/wisent.el --- GNU Bison for Emacs - Runtime 1;;; semantic/wisent/wisent.el --- GNU Bison for Emacs - Runtime -*- lexical-binding: t; -*-
2 2
3;;; Copyright (C) 2002-2007, 2009-2021 Free Software Foundation, Inc. 3;;; Copyright (C) 2002-2007, 2009-2021 Free Software Foundation, Inc.
4 4
@@ -139,7 +139,7 @@ POSITIONS are available."
139 "Print a one-line message if `wisent-parse-verbose-flag' is set. 139 "Print a one-line message if `wisent-parse-verbose-flag' is set.
140Pass STRING and ARGS arguments to `message'." 140Pass STRING and ARGS arguments to `message'."
141 (and wisent-parse-verbose-flag 141 (and wisent-parse-verbose-flag
142 (apply 'message string args))) 142 (apply #'message string args)))
143 143
144;;;; -------------------- 144;;;; --------------------
145;;;; The LR parser engine 145;;;; The LR parser engine
@@ -147,13 +147,11 @@ Pass STRING and ARGS arguments to `message'."
147 147
148(defcustom wisent-parse-max-stack-size 500 148(defcustom wisent-parse-max-stack-size 500
149 "The parser stack size." 149 "The parser stack size."
150 :type 'integer 150 :type 'integer)
151 :group 'wisent)
152 151
153(defcustom wisent-parse-max-recover 3 152(defcustom wisent-parse-max-recover 3
154 "Number of tokens to shift before turning off error status." 153 "Number of tokens to shift before turning off error status."
155 :type 'integer 154 :type 'integer)
156 :group 'wisent)
157 155
158(defvar wisent-discarding-token-functions nil 156(defvar wisent-discarding-token-functions nil
159 "List of functions to be called when discarding a lexical token. 157 "List of functions to be called when discarding a lexical token.
@@ -397,9 +395,9 @@ automaton has only one entry point."
397 (wisent-error 395 (wisent-error
398 (format "Syntax error, unexpected %s, expecting %s" 396 (format "Syntax error, unexpected %s, expecting %s"
399 (wisent-token-to-string wisent-input) 397 (wisent-token-to-string wisent-input)
400 (mapconcat 'wisent-item-to-string 398 (mapconcat #'wisent-item-to-string
401 (delq wisent-error-term 399 (delq wisent-error-term
402 (mapcar 'car (cdr choices))) 400 (mapcar #'car (cdr choices)))
403 ", ")))) 401 ", "))))
404 ;; Increment the error counter 402 ;; Increment the error counter
405 (setq wisent-nerrs (1+ wisent-nerrs)) 403 (setq wisent-nerrs (1+ wisent-nerrs))