1, save all REPL process in Emacs c-x c-w file as Save
The execution statement is not correctly parsed by (load "Foo.lisp") because only the definition statement can execute correctly (load "Foo.lisp")
So the script was written like this, the parse_lisp_code.sh.
#!/bin/bash
If [-N "$"]; Then
Sed ' s/cl-user>//' | Expand-t 8 | Egrep ' ^ *\ (def|^ {8,} ' >> ' Code_${1} '
Else
echo "Please input Lisp file name"
Fi
Run the script sh parse_lisp_code.sh cd.lisp
Command explanation:
Use SED to delete a prompt cl-user
The LISP definition statement starts with a def or a tab, as follows
Cl-user> (Defun dump-db () $
^i (dolist (CD *db*) $
^i (Format T "~{~a: ~10t~a~%~}~%" CD)) $
So using grep to filter out the line of n spaces after each line, plus (Def or tab lines,
But finding grep can't match tabs,
So use EXPAND-T 8 foo > bar to convert a tab to 8 spaces
Ps
SBCL extracting Lisp code from REPL