Next Prev Up Top Contents Index



Establishes a parser for top level forms with the given definer.




define-form-parser definer-and-options &optional parameters &body body => parser



A symbol definer naming a definer of functions, macros, variables and so on, or a list ( definer options ) where options is a plist of keys and values.


nil , or list of parameters in the top level form.


The body of a parser function.



A form parser function.


The macro define-form-parser associates a form parser function with the definer named by definer .

options is a plist with the following keys allowed:



If parameters is supplied, then the form parser function is defined with the code in body . Otherwise the parser function is expected to be supplied as the value of the key :parser in the plist options, or you can specify as an alias a definer with an existing form parser via the :alias key in options .

Lispworks contains predefined form parser functions for the Common Lisp definers defun , defmethod , defgeneric , defvar , defparameter , defconstant , defstruct , defclass , defmacro and deftype and for LispWorks definers such as fli:define-foreign-type and dspec:define-form-parser itself.

When a defining symbol definer has an associated form parser, this parser function is used by the source location commands such as Expression > Find Source in the Common LispWorks development environment. Having identified the file where the definition spec was recorded, LispWorks parses the top level forms in the file looking for the one which matches the definition spec. When found, this match is displayed.


Place these defining forms in a file and load it:

(defmacro parameterdef  (value name)
  `(defparameter ,name ,value))
(dspec:define-form-parser parameterdef (value name)
  `(defparameter ,name))
(parameterdef 42 *foo*)

Now the source of the definition of *foo* is displayed correctly by the source location commands. Without the form parser, this and related commands know that the definition is in the file, but cannot find the defining top level form.

In this second example note the use of define-dspec-alias to inform the dspec system that my-defmethod is simply another way of doing defmethod :

(defmacro my-defmethod (name args &body body)
  `(defmethod ,name ,args 
(dspec:define-dspec-alias my-defmethod 
    (name &rest args)
  `(defmethod ,name ,@args))
(my-defmethod foo ((x number)) 
         #.(dspec:get-form-parser 'defmethod))))
See also


LispWorks Reference Manual - 25 Jul 2003

Next Prev Up Top Contents Index