git » jacl.git » master » tree

[master] / list-operators.lisp

#!/usr/bin/sbcl --script

(defun cl-op-form? (form)
  (and (listp form)
       (symbolp (car form))
       (not (keywordp (car form)))
       (not (member (car form) lambda-list-keywords))
       (find-symbol (symbol-name (car form)) :cl)))

(defun gather-cl-ops (form)
  (cond ((cl-op-form? form)
        (cons (car form) (mapcan #'gather-cl-ops form)))
        ((listp form)
         (mapcan #'gather-cl-ops form))))

(defun read-forms (stream)
  (loop with eof = (gensym)
        for form = (ignore-errors (read stream nil eof nil))
        while (not (eq form eof))
        nconc (gather-cl-ops form) into ops
        finally (return (sort (remove-duplicates ops) #'string<))))

(defvar *ignore* '(declare speed))

(loop for op in (read-forms *standard-input*)
      when (not (member op *ignore*))
      do (format t "~A~%" op))