1 ;;; cl-specs.el --- Edebug specs for cl.el -*- no-byte-compile: t -*-
3 ;; Copyright (C) 1993 Free Software Foundation, Inc.
4 ;; Author: Daniel LaLiberte <liberte@holonexus.org>
5 ;; Keywords: lisp, tools, maint
8 ;; cl-specs.el|Daniel LaLiberte|liberte@holonexus.org
9 ;; |Edebug specs for cl.el
10 ;; |$Date: 2001/07/16 12:22:59 $|1.1|
12 ;; This file is part of GNU Emacs.
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it 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 ;; GNU Emacs 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 GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
31 ;; These specs are to be used with edebug.el version 3.3 or later and
32 ;; cl.el version 2.03 or later, by Dave Gillespie <daveg@synaptics.com>.
34 ;; This file need not be byte-compiled, but it shouldn't hurt.
39 ;; Do the above provide before the following require.
40 ;; Otherwise if you load this before edebug if cl is already loaded
41 ;; an infinite loading loop would occur.
46 (def-edebug-spec block
(symbolp body
))
47 (def-edebug-spec return
(&optional form
))
48 (def-edebug-spec return-from
(symbolp &optional form
))
52 (def-edebug-spec case
(form &rest
(sexp body
)))
53 (def-edebug-spec ecase case
)
55 ((&rest
&or symbolp
(symbolp &optional form form
))
57 cl-declarations body
))
58 (def-edebug-spec do
* do
)
59 (def-edebug-spec dolist
60 ((symbolp form
&optional form
) cl-declarations body
))
61 (def-edebug-spec dotimes dolist
)
62 (def-edebug-spec do-symbols
63 ((symbolp &optional form form
) cl-declarations body
))
64 (def-edebug-spec do-all-symbols
65 ((symbolp &optional form
) cl-declarations body
))
69 (def-edebug-spec multiple-value-list
(form))
70 (def-edebug-spec multiple-value-call
(function-form body
))
71 (def-edebug-spec multiple-value-bind
72 ((&rest symbolp
) form cl-declarations body
))
73 (def-edebug-spec multiple-value-setq
((&rest symbolp
) form
))
74 (def-edebug-spec multiple-value-prog1
(form body
))
78 (def-edebug-spec lexical-let let
)
79 (def-edebug-spec lexical-let
* let
)
81 (def-edebug-spec psetq setq
)
82 (def-edebug-spec progv
(form form body
))
84 (def-edebug-spec flet
((&rest
(defun*)) cl-declarations body
))
85 (def-edebug-spec labels flet
)
87 (def-edebug-spec macrolet
88 ((&rest
(&define name
(&rest arg
) cl-declarations-or-string def-body
))
89 cl-declarations body
))
91 (def-edebug-spec symbol-macrolet
92 ((&rest
(symbol sexp
)) cl-declarations body
))
94 (def-edebug-spec destructuring-bind
95 (&define cl-macro-list form cl-declarations def-body
))
99 (def-edebug-spec setf
(&rest
[place form
])) ;; sexp is not specific enough
100 (def-edebug-spec psetf setf
)
102 (def-edebug-spec letf
;; *not* available in Common Lisp
103 ((&rest
(gate place
&optional form
))
105 (def-edebug-spec letf
* letf
)
108 (def-edebug-spec defsetf
110 [&or
[symbolp
&optional stringp
]
111 [cl-lambda-list
(symbolp)]]
112 cl-declarations-or-string def-body
))
114 (def-edebug-spec define-setf-method
115 (&define name cl-lambda-list cl-declarations-or-string def-body
))
117 (def-edebug-spec define-modify-macro
118 (&define name cl-lambda-list
;; should exclude &key
119 symbolp
&optional stringp
))
121 (def-edebug-spec callf
(function* place
&rest form
))
122 (def-edebug-spec callf2
(function* form place
&rest form
))
124 ;; Other operations on places
126 (def-edebug-spec remf
(place form
))
128 (def-edebug-spec incf
(place &optional form
))
129 (def-edebug-spec decf incf
)
130 (def-edebug-spec push
(form place
)) ; different for CL
131 (def-edebug-spec pushnew
133 &or
[[&or
":test" ":test-not" ":key"] function-form
]
134 [edebug-keywordp form
]))
135 (def-edebug-spec pop
(place)) ; different for CL
137 (def-edebug-spec shiftf
(&rest place
)) ;; really [&rest place] form
138 (def-edebug-spec rotatef
(&rest place
))
141 ;; Functions with function args. These are only useful if the
142 ;; function arg is quoted with ' instead of function.
144 (def-edebug-spec some
(function-form form
&rest form
))
145 (def-edebug-spec every some
)
146 (def-edebug-spec notany some
)
147 (def-edebug-spec notevery some
)
151 (def-edebug-spec map
(form function-form form
&rest form
))
152 (def-edebug-spec maplist
(function-form form
&rest form
))
153 (def-edebug-spec mapc maplist
)
154 (def-edebug-spec mapl maplist
)
155 (def-edebug-spec mapcan maplist
)
156 (def-edebug-spec mapcon maplist
)
160 (def-edebug-spec reduce
(function-form form
&rest form
))
162 ;; Types and assertions
164 (def-edebug-spec cl-type-spec
(sexp)) ;; not worth the trouble to specify, yet.
166 (def-edebug-spec deftype defmacro
*)
167 (def-edebug-spec check-type
(place cl-type-spec
&optional stringp
))
168 ;; (def-edebug-spec assert (form &optional form stringp &rest form))
169 (def-edebug-spec assert
(form &rest form
))
170 (def-edebug-spec typecase
(form &rest
([&or cl-type-spec
"otherwise"] body
)))
171 (def-edebug-spec etypecase typecase
)
173 (def-edebug-spec ignore-errors t
)
175 ;; Time of Evaluation
177 (def-edebug-spec eval-when
178 ((&rest
&or
"compile" "load" "eval") body
))
179 (def-edebug-spec load-time-value
(form &optional
&or
"t" "nil"))
183 (def-edebug-spec cl-decl-spec
184 ((symbolp &rest sexp
)))
186 (def-edebug-spec cl-declarations
187 (&rest
("declare" &rest cl-decl-spec
)))
189 (def-edebug-spec cl-declarations-or-string
190 (&or stringp cl-declarations
))
192 (def-edebug-spec declaim
(&rest cl-decl-spec
))
193 (def-edebug-spec declare
(&rest cl-decl-spec
)) ;; probably not needed.
194 (def-edebug-spec locally
(cl-declarations &rest form
))
195 (def-edebug-spec the
(cl-type-spec form
))
197 ;;======================================================
200 (def-edebug-spec cl-lambda-list
202 [&optional
["&optional" cl-
&optional-arg
&rest cl-
&optional-arg
]]
203 [&optional
["&rest" arg
]]
204 [&optional
["&key" [cl-
&key-arg
&rest cl-
&key-arg
]
205 &optional
"&allow-other-keys"]]
206 [&optional
["&aux" &rest
207 &or
(symbolp &optional def-form
) symbolp
]]
210 (def-edebug-spec cl-
&optional-arg
211 (&or
(arg &optional def-form arg
) arg
))
213 (def-edebug-spec cl-
&key-arg
214 (&or
([&or
(symbolp arg
) arg
] &optional def-form arg
) arg
))
216 ;; The lambda list for macros is different from that of normal lambdas.
217 ;; Note that &environment is only allowed as first or last items in the
220 (def-edebug-spec cl-macro-list
221 (([&optional
"&environment" arg
]
223 [&optional
["&optional" &rest
224 &or
(cl-macro-arg &optional def-form cl-macro-arg
) arg
]]
225 [&optional
[[&or
"&rest" "&body"] cl-macro-arg
]]
226 [&optional
["&key" [&rest
227 [&or
([&or
(symbolp cl-macro-arg
) arg
]
228 &optional def-form cl-macro-arg
)
230 &optional
"&allow-other-keys"]]
231 [&optional
["&aux" &rest
232 &or
(symbolp &optional def-form
) symbolp
]]
233 [&optional
"&environment" arg
]
236 (def-edebug-spec cl-macro-arg
237 (&or arg cl-macro-list1
))
239 (def-edebug-spec cl-macro-list1
240 (([&optional
"&whole" arg
] ;; only allowed at lower levels
242 [&optional
["&optional" &rest
243 &or
(cl-macro-arg &optional def-form cl-macro-arg
) arg
]]
244 [&optional
[[&or
"&rest" "&body"] cl-macro-arg
]]
245 [&optional
["&key" [&rest
246 [&or
([&or
(symbolp cl-macro-arg
) arg
]
247 &optional def-form cl-macro-arg
)
249 &optional
"&allow-other-keys"]]
250 [&optional
["&aux" &rest
251 &or
(symbolp &optional def-form
) symbolp
]]
255 (def-edebug-spec defun
*
256 ;; Same as defun but use cl-lambda-list.
258 ("setf" :name setf name
)]
260 cl-declarations-or-string
261 [&optional
("interactive" interactive
)]
263 (def-edebug-spec defsubst
* defun
*)
265 (def-edebug-spec defmacro
*
266 (&define name cl-macro-list cl-declarations-or-string def-body
))
267 (def-edebug-spec define-compiler-macro defmacro
*)
270 (def-edebug-spec function
*
271 (&or symbolp cl-lambda-expr
))
273 (def-edebug-spec cl-lambda-expr
274 (&define
("lambda" cl-lambda-list
275 ;;cl-declarations-or-string
276 ;;[&optional ("interactive" interactive)]
279 ;; Redefine function-form to also match function*
280 (def-edebug-spec function-form
281 ;; form at the end could also handle "function",
282 ;; but recognize it specially to avoid wrapping function forms.
283 (&or
([&or
"quote" "function"] &or symbolp lambda-expr
)
284 ("function*" function
*)
287 ;;======================================================
289 ;; (def-edebug-spec defstruct (&rest sexp)) would be sufficient, but...
291 ;; defstruct may contain forms that are evaluated when a structure is created.
292 (def-edebug-spec defstruct
293 (&define
; makes top-level form not be wrapped
297 (&or
[":conc-name" &or stringp
"nil"]
298 [":constructor" symbolp
&optional cl-lambda-list
]
300 [":predicate" symbolp
]
301 [":include" symbolp
&rest sexp
];; not finished
302 ;; The following are not supported.
303 ;; [":print-function" ...]
305 ;; [":initial-offset" ...]
308 ;; All the above is for the following def-form.
309 &rest
&or symbolp
(symbolp def-form
&optional
":read-only" sexp
)))
311 ;;======================================================
314 ;; The loop macro is very complex, and a full spec is found below.
315 ;; The following spec only minimally specifies that
316 ;; parenthesized forms are executable, but single variables used as
317 ;; expressions will be missed. You may want to use this if the full
318 ;; spec causes problems for you.
320 (def-edebug-spec loop
321 (&rest
&or symbolp form
))
323 ;; Below is a complete spec for loop, in several parts that correspond
324 ;; to the syntax given in CLtL2. The specs do more than specify where
325 ;; the forms are; it also specifies, as much as Edebug allows, all the
326 ;; syntactically legal loop clauses. The disadvantage of this
327 ;; completeness is rigidity, but the "for ... being" clause allows
328 ;; arbitrary extensions of the form: [symbolp &rest &or symbolp form].
330 (def-edebug-spec loop
331 ([&optional
["named" symbolp
]]
341 (def-edebug-spec loop-with
344 [&optional
["=" form
]]
345 &rest
["and" loop-var
347 [&optional
["=" form
]]]))
349 (def-edebug-spec loop-for-as
350 ([&or
"for" "as"] loop-for-as-subclause
351 &rest
["and" loop-for-as-subclause
]))
353 (def-edebug-spec loop-for-as-subclause
357 [[&or
"in" "on" "in-ref" "across-ref"]
358 form
&optional
["by" function-form
]]
360 ["=" form
&optional
["then" form
]]
365 [[&or
"element" "elements"]
366 [&or
"of" "in" "of-ref"] form
367 &optional
"using" ["index" symbolp
]];; is this right?
368 [[&or
"hash-key" "hash-keys"
369 "hash-value" "hash-values"]
371 hash-table-p
&optional
["using" ([&or
"hash-value" "hash-values"
372 "hash-key" "hash-keys"] sexp
)]]
374 [[&or
"symbol" "present-symbol" "external-symbol"
375 "symbols" "present-symbols" "external-symbols"]
376 [&or
"in" "of"] package-p
]
378 ;; Extensions for Emacs Lisp, including Lucid Emacs.
379 [[&or
"frame" "frames"
383 [[&or
"window" "windows"]
384 [&or
"of" "in"] form
]
386 [[&or
"overlay" "overlays"
389 &optional
[[&or
"from" "to"] form
]]
391 [[&or
"interval" "intervals"]
393 &optional
[[&or
"from" "to"] form
]
396 [[&or
"key-code" "key-codes"
398 "key-binding" "key-bindings"]
400 &optional
["using" ([&or
"key-code" "key-codes"
402 "key-binding" "key-bindings"]
404 ;; For arbitrary extensions, recognize anything else.
405 [symbolp
&rest
&or symbolp form
]
408 ;; arithmetic - must be last since all parts are optional.
409 [[&optional
[[&or
"from" "downfrom" "upfrom"] form
]]
410 [&optional
[[&or
"to" "downto" "upto" "below" "above"] form
]]
411 [&optional
["by" form
]]
414 (def-edebug-spec loop-initial-final
416 ;; [&optional &or "do" "doing"] ;; CLtL2 doesn't allow this.
417 &rest loop-non-atomic-expr
]
419 [[&optional
&or
"do" "doing"] &rest loop-non-atomic-expr
]
422 (def-edebug-spec loop-and-clause
423 (loop-clause &rest
["and" loop-clause
]))
425 (def-edebug-spec loop-clause
427 [[&or
"while" "until" "always" "never" "thereis"] form
]
429 [[&or
"collect" "collecting"
432 "concat" "vconcat"] form
433 [&optional
["into" loop-var
]]]
435 [[&or
"count" "counting"
437 "maximize" "maximizing"
438 "minimize" "minimizing"] form
439 [&optional
["into" loop-var
]]
442 [[&or
"if" "when" "unless"]
444 [&optional
["else" loop-and-clause
]]
447 [[&or
"do" "doing"] &rest loop-non-atomic-expr
]
453 (def-edebug-spec loop-non-atomic-expr
456 (def-edebug-spec loop-var
457 ;; The symbolp must be last alternative to recognize e.g. (a b . c)
459 ;; (loop-var . [&or nil loop-var])
460 ;; (symbolp . [&or nil loop-var])
461 ;; (symbolp . loop-var)
462 ;; (symbolp . (symbolp . [&or nil loop-var]))
463 ;; (symbolp . (symbolp . loop-var))
464 ;; (symbolp . (symbolp . symbolp)) == (symbolp symbolp . symbolp)
465 (&or
(loop-var .
[&or nil loop-var
]) [gate symbolp
]))
467 (def-edebug-spec loop-type-spec
468 (&optional
["of-type" loop-d-type-spec
]))
470 (def-edebug-spec loop-d-type-spec
471 (&or
(loop-d-type-spec .
[&or nil loop-d-type-spec
]) cl-type-spec
))
473 ;;; cl-specs.el ends here