1 ;;; cl-specs.el --- Edebug specs for cl.el
3 ;; Copyright (C) 1993, 2003 Free Software Foundation, Inc.
4 ;; Copyright (C) 2002 Ben Wing.
5 ;; Author: Daniel LaLiberte <liberte@holonexus.org>
6 ;; Keywords: lisp, tools, maint
9 ;; cl-specs.el|Daniel LaLiberte|liberte@holonexus.org
10 ;; |Edebug specs for cl.el
12 ;; This file is part of XEmacs.
14 ;; XEmacs is free software; you can redistribute it and/or modify it
15 ;; under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
19 ;; XEmacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with XEmacs; see the file COPYING. If not, write to the Free
26 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
29 ;;; Synched up with: GNU Emacs 21.3.
33 ;; These specs are to be used with edebug.el version 3.3 or later and
34 ;; cl.el version 2.03 or later, by Dave Gillespie <daveg@synaptics.com>.
36 ;; This file need not be byte-compiled, but it shouldn't hurt.
41 ;; Do the above provide before the following require.
42 ;; Otherwise if you load this before edebug if cl is already loaded
43 ;; an infinite loading loop would occur.
48 (def-edebug-spec block (symbolp body))
49 (def-edebug-spec return (&optional form))
50 (def-edebug-spec return-from (symbolp &optional form))
54 (def-edebug-spec case (form &rest (sexp body)))
55 (def-edebug-spec ecase case)
57 ((&rest &or symbolp (symbolp &optional form form))
59 cl-declarations body))
60 (def-edebug-spec do* do)
61 (def-edebug-spec dolist
62 ((symbolp form &optional form) cl-declarations body))
63 (def-edebug-spec dotimes dolist)
64 (def-edebug-spec do-symbols
65 ((symbolp &optional form form) cl-declarations body))
66 (def-edebug-spec do-all-symbols
67 ((symbolp &optional form) cl-declarations body))
71 (def-edebug-spec multiple-value-list (form))
72 (def-edebug-spec multiple-value-call (function-form body))
73 (def-edebug-spec multiple-value-bind
74 ((&rest symbolp) form cl-declarations body))
75 (def-edebug-spec multiple-value-setq ((&rest symbolp) form))
76 (def-edebug-spec multiple-value-prog1 (form body))
80 (def-edebug-spec lexical-let let)
81 (def-edebug-spec lexical-let* let)
83 (def-edebug-spec psetq setq)
84 (def-edebug-spec progv (form form body))
86 (def-edebug-spec flet ((&rest (defun*)) cl-declarations body))
87 (def-edebug-spec labels flet)
89 (def-edebug-spec macrolet
90 ((&rest (&define name (&rest arg) cl-declarations-or-string def-body))
91 cl-declarations body))
93 (def-edebug-spec symbol-macrolet
94 ((&rest (symbol sexp)) cl-declarations body))
96 ;; XEmacs change: Should look like inner macro lists, not outer ones,
97 ;; because &environment is not allowed. --ben
98 (def-edebug-spec destructuring-bind
99 (&define cl-macro-list1 form cl-declarations def-body))
103 (def-edebug-spec setf (&rest [place form])) ;; sexp is not specific enough
104 (def-edebug-spec psetf setf)
106 (def-edebug-spec letf ;; *not* available in Common Lisp
107 ((&rest (gate place &optional form))
109 (def-edebug-spec letf* letf)
112 (def-edebug-spec defsetf
114 [&or [symbolp &optional stringp]
115 [cl-lambda-list (symbolp)]]
116 cl-declarations-or-string def-body))
118 (def-edebug-spec define-setf-method
119 (&define name cl-lambda-list cl-declarations-or-string def-body))
121 (def-edebug-spec define-modify-macro
122 (&define name cl-lambda-list ;; should exclude &key
123 symbolp &optional stringp))
125 (def-edebug-spec callf (function* place &rest form))
126 (def-edebug-spec callf2 (function* form place &rest form))
128 ;; Other operations on places
130 (def-edebug-spec remf (place form))
132 (def-edebug-spec incf (place &optional form))
133 (def-edebug-spec decf incf)
134 (def-edebug-spec push (form place)) ; different for CL
135 (def-edebug-spec pushnew
137 &or [[&or ":test" ":test-not" ":key"] function-form]
139 (def-edebug-spec pop (place)) ; different for CL
141 (def-edebug-spec shiftf (&rest place)) ;; really [&rest place] form
142 (def-edebug-spec rotatef (&rest place))
145 ;; Functions with function args. These are only useful if the
146 ;; function arg is quoted with ' instead of function.
148 (def-edebug-spec some (function-form form &rest form))
149 (def-edebug-spec every some)
150 (def-edebug-spec notany some)
151 (def-edebug-spec notevery some)
155 (def-edebug-spec map (form function-form form &rest form))
156 (def-edebug-spec maplist (function-form form &rest form))
157 (def-edebug-spec mapc maplist)
158 (def-edebug-spec mapl maplist)
159 (def-edebug-spec mapcan maplist)
160 (def-edebug-spec mapcon maplist)
164 (def-edebug-spec reduce (function-form form &rest form))
166 ;; Types and assertions
168 (def-edebug-spec cl-type-spec (sexp)) ;; not worth the trouble to specify, yet.
170 (def-edebug-spec deftype defmacro*)
171 (def-edebug-spec check-type (place cl-type-spec &optional stringp))
172 ;; (def-edebug-spec assert (form &optional form stringp &rest form))
173 (def-edebug-spec assert (form &rest form))
174 (def-edebug-spec typecase (form &rest ([&or cl-type-spec "otherwise"] body)))
175 (def-edebug-spec etypecase typecase)
177 (def-edebug-spec ignore-errors t)
179 ;; Time of Evaluation
181 (def-edebug-spec eval-when
182 ((&rest &or "compile" "load" "eval") body))
183 (def-edebug-spec load-time-value (form &optional &or "t" "nil"))
187 (def-edebug-spec cl-decl-spec
188 ((symbolp &rest sexp)))
190 (def-edebug-spec cl-declarations
191 (&rest ("declare" &rest cl-decl-spec)))
193 (def-edebug-spec cl-declarations-or-string
194 (&or stringp cl-declarations))
196 (def-edebug-spec declaim (&rest cl-decl-spec))
197 (def-edebug-spec declare (&rest cl-decl-spec)) ;; probably not needed.
198 (def-edebug-spec locally (cl-declarations &rest form))
199 (def-edebug-spec the (cl-type-spec form))
201 ;;======================================================
204 (def-edebug-spec cl-lambda-list
206 [&optional ["&optional" cl-&optional-arg &rest cl-&optional-arg]]
207 [&optional ["&rest" arg]]
208 [&optional ["&key" [cl-&key-arg &rest cl-&key-arg]
209 &optional "&allow-other-keys"]]
210 [&optional ["&aux" &rest
211 &or (symbolp &optional def-form) symbolp]]
214 (def-edebug-spec cl-&optional-arg
215 (&or (arg &optional def-form arg) arg))
217 (def-edebug-spec cl-&key-arg
218 (&or ([&or (symbolp arg) arg] &optional def-form arg) arg))
220 ;; The lambda list for macros is different from that of normal lambdas.
221 ;; Note that &environment is only allowed as first or last items in the
224 ;; XEmacs change. #### In fact, CLTL2 says &environment can occur anywhere
225 ;; in the list. The list can also be dotted. Yuck, &environment can occur
226 ;; only once, even though anywhere in the list -- how do I encode that?
227 ;; Also had to add the &or and separate; otherwise dotted specs were
228 ;; causing errors. --ben
230 (def-edebug-spec cl-macro-list
232 ([&optional "&environment" arg]
233 [&optional "&whole" arg]
234 [&optional "&environment" arg]
238 ([&optional "&environment" arg]
239 [&optional "&whole" arg]
240 [&optional "&environment" arg]
242 [&optional "&environment" arg]
243 [&optional ["&optional" &rest
244 &or (cl-macro-arg &optional def-form cl-macro-arg) arg]]
245 [&optional "&environment" arg]
246 [&optional [[&or "&rest" "&body"] cl-macro-arg]]
247 [&optional "&environment" arg]
248 [&optional ["&key" [&rest
249 [&or ([&or (symbolp cl-macro-arg) arg]
250 &optional def-form cl-macro-arg)
252 &optional "&allow-other-keys"]]
253 [&optional "&environment" arg]
254 [&optional ["&aux" &rest
255 &or (symbolp &optional def-form) symbolp]]
256 [&optional "&environment" arg]
259 (def-edebug-spec cl-macro-arg
260 (&or arg cl-macro-list1))
262 (def-edebug-spec cl-macro-list1
264 ([&optional "&whole" arg]
268 ([&optional "&whole" arg]
270 [&optional ["&optional" &rest
271 &or (cl-macro-arg &optional def-form cl-macro-arg) arg]]
272 [&optional [[&or "&rest" "&body"] cl-macro-arg]]
273 [&optional ["&key" [&rest
274 [&or ([&or (symbolp cl-macro-arg) arg]
275 &optional def-form cl-macro-arg)
277 &optional "&allow-other-keys"]]
278 [&optional ["&aux" &rest
279 &or (symbolp &optional def-form) symbolp]]
283 (def-edebug-spec defun*
284 ;; Same as defun but use cl-lambda-list.
286 ("setf" :name setf name)]
288 cl-declarations-or-string
289 [&optional ("interactive" interactive)]
291 (def-edebug-spec defsubst* defun*)
293 (def-edebug-spec defmacro*
294 (&define name cl-macro-list cl-declarations-or-string def-body))
295 (def-edebug-spec define-compiler-macro defmacro*)
298 (def-edebug-spec function*
299 (&or symbolp cl-lambda-expr))
301 (def-edebug-spec cl-lambda-expr
302 (&define ("lambda" cl-lambda-list
303 ;;cl-declarations-or-string
304 ;;[&optional ("interactive" interactive)]
307 ;; Redefine function-form to also match function*
308 (def-edebug-spec function-form
309 ;; form at the end could also handle "function",
310 ;; but recognize it specially to avoid wrapping function forms.
311 (&or ([&or "quote" "function"] &or symbolp lambda-expr)
312 ("function*" function*)
315 ;;======================================================
317 ;; (def-edebug-spec defstruct (&rest sexp)) would be sufficient, but...
319 ;; defstruct may contain forms that are evaluated when a structure is created.
320 (def-edebug-spec defstruct
321 (&define ; makes top-level form not be wrapped
325 (&or [":conc-name" &or stringp "nil"]
326 [":constructor" symbolp &optional cl-lambda-list]
328 [":predicate" symbolp]
329 [":include" symbolp &rest sexp];; not finished
330 ;; The following are not supported.
331 ;; [":print-function" ...]
333 ;; [":initial-offset" ...]
336 ;; All the above is for the following def-form.
337 &rest &or symbolp (symbolp def-form &optional ":read-only" sexp)))
339 ;;======================================================
342 ;; The loop macro is very complex, and a full spec is found below.
343 ;; The following spec only minimally specifies that
344 ;; parenthesized forms are executable, but single variables used as
345 ;; expressions will be missed. You may want to use this if the full
346 ;; spec causes problems for you.
348 (def-edebug-spec loop
349 (&rest &or symbolp form))
351 ;; Below is a complete spec for loop, in several parts that correspond
352 ;; to the syntax given in CLtL2. The specs do more than specify where
353 ;; the forms are; it also specifies, as much as Edebug allows, all the
354 ;; syntactically legal loop clauses. The disadvantage of this
355 ;; completeness is rigidity, but the "for ... being" clause allows
356 ;; arbitrary extensions of the form: [symbolp &rest &or symbolp form].
358 (def-edebug-spec loop
359 ([&optional ["named" symbolp]]
369 (def-edebug-spec loop-with
372 [&optional ["=" form]]
373 &rest ["and" loop-var
375 [&optional ["=" form]]]))
377 (def-edebug-spec loop-for-as
378 ([&or "for" "as"] loop-for-as-subclause
379 &rest ["and" loop-for-as-subclause]))
381 (def-edebug-spec loop-for-as-subclause
385 [[&or "in" "on" "in-ref" "across-ref"]
386 form &optional ["by" function-form]]
388 ["=" form &optional ["then" form]]
393 [[&or "element" "elements"]
394 [&or "of" "in" "of-ref"] form
395 &optional "using" ["index" symbolp]];; is this right?
396 [[&or "hash-key" "hash-keys"
397 "hash-value" "hash-values"]
399 hash-table-p &optional ["using" ([&or "hash-value" "hash-values"
400 "hash-key" "hash-keys"] sexp)]]
402 [[&or "symbol" "present-symbol" "external-symbol"
403 "symbols" "present-symbols" "external-symbols"]
404 [&or "in" "of"] package-p]
406 ;; Extensions for Emacs Lisp, including Lucid Emacs.
407 [[&or "frame" "frames"
411 [[&or "window" "windows"]
412 [&or "of" "in"] form]
414 [[&or "overlay" "overlays"
417 &optional [[&or "from" "to"] form]]
419 [[&or "interval" "intervals"]
421 &optional [[&or "from" "to"] form]
424 [[&or "key-code" "key-codes"
426 "key-binding" "key-bindings"]
428 &optional ["using" ([&or "key-code" "key-codes"
430 "key-binding" "key-bindings"]
432 ;; For arbitrary extensions, recognize anything else.
433 [symbolp &rest &or symbolp form]
436 ;; arithmetic - must be last since all parts are optional.
437 [[&optional [[&or "from" "downfrom" "upfrom"] form]]
438 [&optional [[&or "to" "downto" "upto" "below" "above"] form]]
439 [&optional ["by" form]]
442 (def-edebug-spec loop-initial-final
444 ;; [&optional &or "do" "doing"] ;; CLtL2 doesn't allow this.
445 &rest loop-non-atomic-expr]
447 [[&optional &or "do" "doing"] &rest loop-non-atomic-expr]
450 (def-edebug-spec loop-and-clause
451 (loop-clause &rest ["and" loop-clause]))
453 (def-edebug-spec loop-clause
455 [[&or "while" "until" "always" "never" "thereis"] form]
457 [[&or "collect" "collecting"
460 "concat" "vconcat"] form
461 [&optional ["into" loop-var]]]
463 [[&or "count" "counting"
465 "maximize" "maximizing"
466 "minimize" "minimizing"] form
467 [&optional ["into" loop-var]]
470 [[&or "if" "when" "unless"]
472 [&optional ["else" loop-and-clause]]
475 [[&or "do" "doing"] &rest loop-non-atomic-expr]
481 (def-edebug-spec loop-non-atomic-expr
484 (def-edebug-spec loop-var
485 ;; The symbolp must be last alternative to recognize e.g. (a b . c)
487 ;; (loop-var . [&or nil loop-var])
488 ;; (symbolp . [&or nil loop-var])
489 ;; (symbolp . loop-var)
490 ;; (symbolp . (symbolp . [&or nil loop-var]))
491 ;; (symbolp . (symbolp . loop-var))
492 ;; (symbolp . (symbolp . symbolp)) == (symbolp symbolp . symbolp)
493 (&or (loop-var . [&or nil loop-var]) [gate symbolp]))
495 (def-edebug-spec loop-type-spec
496 (&optional ["of-type" loop-d-type-spec]))
498 (def-edebug-spec loop-d-type-spec
499 (&or (loop-d-type-spec . [&or nil loop-d-type-spec]) cl-type-spec))
501 ;;; arch-tag: b29aa3c2-cf67-4af8-9ee1-318fea61b478
502 ;;; cl-specs.el ends here