SBCL extracting Lisp code from REPL

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.