0

I have a Lisp file with some functions defined [ (defun ... ].

Is there an easy way to get all function names defined in the script using Java?

3 Answers 3

1

Perhaps you can use some of the code from A Small Lisp interpreter in Java

Sign up to request clarification or add additional context in comments.

Comments

0

If you want to know, which functions are defined in a certain package, you cane use with-package-iterator macro. Like this:

(with-package-iterator (next (find-package 'test) :internal)
  (loop :for (more? sym) := (multiple-value-list (next))
        :if (fboundp sym) :collect sym :into rez 
        :else :unless more? :do (return rez)))

If you want to just extract functions from a script(-file), the easiest way seems to be scanning it with a regex "\\(defun (.+)\\s" or something similar.

Comments

0

In very simple cases, you can use regular expressions. In slightly less simple cases, implementing an S-expression reader might be a reasonable approach (you might even get away with ignoring reader macros altogether). In the general case, though, especially if macrology is involved, consider embedding Armed Bear Common Lisp, which is a Java implementation of Common Lisp, and using the with-package-iterator form Vsevolod mentioned.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.