/[slime]/slime/swank.lisp
ViewVC logotype

Diff of /slime/swank.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.496 by mkoeppe, Thu Aug 23 22:50:40 2007 UTC revision 1.497 by trittweiler, Fri Aug 24 13:55:25 2007 UTC
# Line 1590  if RAW-SPEC could not be parsed. Line 1590  if RAW-SPEC could not be parsed.
1590    
1591  A ``raw form spec'' can be either:  A ``raw form spec'' can be either:
1592    
1593    i)   a string representing a Common Lisp symbol,    i)   a list of strings representing a Common Lisp form
1594    
1595    ii)  a string representing a Common Lisp form,    ii)  one of:
1596    
1597    iii) a list:       a)  (:declaration decl-identifier declspec)
1598    
1599       a)  (:declaration declspec)             where DECL-IDENTIFIER is the string representation of a /decl identifier/,
1600                     DECLSPEC is the string representation of a /declaration specifier/.
1601    
1602             where DECLSPEC is the string representation of a /declaration specifier/,       b)  (:type-specifier typespec-operator typespec)
   
      b)  (:type-specifier typespec)  
1603    
1604             where TYPESPEC is the string representation of a /type specifier/.             where TYPESPEC-OPERATOR is the string representation of the CAR of a /type specifier/,
1605                     TYPESPEC is the string representation of a /type specifier/.
1606    
1607         (DECL-IDENTIFIER, and TYPESPEC-OPERATOR are actually redundant (as they're both
1608         already provided in DECLSPEC, or TYPESPEC respectively, but this separation
1609         allows to check if these raw form specs are valid before the whole spec is READ,
1610         and thus all contained symbols interned.)
1611    
1612  A ``form spec'' is either  A ``form spec'' is either
1613    
# Line 1619  A ``form spec'' is either Line 1623  A ``form spec'' is either
1623    
1624  Examples:  Examples:
1625    
1626    \"defmethod\"                       =>  (defmethod)    (\"defmethod\")                     =>  (defmethod)
1627    \"cl:defmethod\"                    =>  (cl:defmethod)    (\"cl:defmethod\")                  =>  (cl:defmethod)
1628    \"(defmethod print-object)\"        =>  (defmethod print-object)    (\"defmethod\" \"print-object\")    =>  (defmethod print-object)
1629    (:declaration \"(optimize)\")       =>  ((:declaration optimize))  
1630    (:declaration \"(type string)\")    =>  ((:declaration type) string)    (:declaration \"optimize\" \"(optimize)\")    =>  ((:declaration optimize))
1631    (:type-specifier \"(float)\")       =>  ((:type-specifier float))    (:declaration \"type\"     \"(type string)\") =>  ((:declaration type) string)
1632    (:type-specifier \"(float 0 100)\") =>  ((:type-specifier float) 0 100)    (:type-specifier \"float\" \"(float)\")       =>  ((:type-specifier float))
1633      (:type-specifier \"float\" \"(float 0 100)\") =>  ((:type-specifier float) 0 100)
1634  "  "
1635    (typecase raw-spec    (flet ((parse-extended-spec (raw-extension-op raw-extension extension-flag)
1636      (string (ensure-list (read-incomplete-form-from-string raw-spec)))             (when (nth-value 1 (parse-symbol raw-extension-op))
1637      (cons                               ; compound form spec               (let ((extension (read-incomplete-form-from-string raw-extension)))
1638       (destructure-case raw-spec                 (unless (recursively-empty-p extension) ; (:DECLARATION "(())") &c.
1639         ((:declaration raw-declspec)                   (destructuring-bind (identifier &rest args) extension
1640          (let ((declspec (from-string raw-declspec)))                     `((,extension-flag ,identifier) ,@args)))))))
1641            (unless (recursively-empty-p declspec) ; (:DECLARATION "(())") &c.      (when (consp raw-spec)
1642              (destructuring-bind (decl-identifier &rest decl-args) declspec        (destructure-case raw-spec
1643                `((:declaration ,decl-identifier) ,@decl-args)))))          ((:declaration raw-decl-identifier raw-declspec)
1644         ((:type-specifier raw-typespec)           (parse-extended-spec raw-decl-identifier raw-declspec :declaration))
1645          (let ((typespec (from-string raw-typespec)))          ((:type-specifier raw-typespec-op raw-typespec)
1646            (unless (recursively-empty-p typespec)           (parse-extended-spec raw-typespec-op raw-typespec :type-specifier))
1647              (destructuring-bind (typespec-op &rest typespec-args) typespec          (t
1648                `((:type-specifier ,typespec-op) ,@typespec-args)))))))           (when (every #'stringp raw-spec)
1649      (otherwise nil)))             (destructuring-bind (raw-operator &rest raw-args) raw-spec
1650                 (multiple-value-bind (operator found?) (parse-symbol raw-operator)
1651                   (when (and found? (valid-operator-symbol-p operator))
1652                     `(,operator ,@(read-incomplete-form-from-string
1653                                    (format nil "(~A)"
1654                                            (apply #'concatenate 'string raw-args)))))))))))))
1655    
1656  (defun split-form-spec (spec)  (defun split-form-spec (spec)
1657    "Returns all three relevant information a ``form spec''    "Returns all three relevant information a ``form spec''
# Line 2432  Examples: Line 2442  Examples:
2442    
2443    (arglist-from-form-spec '(defun foo))    (arglist-from-form-spec '(defun foo))
2444    
2445        ~=> (args &body body))        ~=> (args &body body)
2446    
2447    (arglist-from-form-spec '(defun foo) :remove-args nil)    (arglist-from-form-spec '(defun foo) :remove-args nil))
2448    
2449        ~=>  (name args &body body))        ~=>  (name args &body body))
2450    

Legend:
Removed from v.1.496  
changed lines
  Added in v.1.497

  ViewVC Help
Powered by ViewVC 1.1.5