Advertisement
Guest User

Untitled

a guest
Apr 27th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. (defmacro defrule (name lambda-list &rest body)
  2. (destructuring-bind (input-parameter &rest other-parameters) lambda-list
  3. `(defun ,(intern (format "parse-%s" name)) ,(cons input-parameter other-parameters)
  4. (unless (zerop (length ,input-parameter))
  5. ,@body))))
  6.  
  7. (macroexpand-1 '(defrule ordinary (input)
  8. (list (substring input 1 nil) (list 'literal (aref input 0)))))
  9. --> (defun parse-ordinary (input) (unless (zerop (length input)) (list (substring input 1 nil) (list (quote literal) (aref input 0)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement