A Simple Sexp Structure Editor

This is a simple sexp structure editor to demonstrate how we can edit lisp sources directly instead of going thru the deserialization and serialization (converting the sexps into a textual representation and using a text editor such as emacs).

This editor manipulates directly the sexp data structure.

It is invoked as (sedit sexp), and returns the modified sexp. (The sexp is modified destructively).

 (sedit (copy-tree '(an example)))
  

At each interaction loop, it prints the whole sexp, showing the selected sub-sexp, and query a command. The list of commands are:

Example:

C/IBCL-USER[4]> (sedit '())

Sexp Editor:
【NIL】
> r
replacement sexp: (let ((*package #.*package*)) (print 'hello))
【(LET ((*PACKAGE #<PACKAGE IMAGE-BASED-COMMON-LISP-USER>)) (PRINT (QUOTE HELLO)))】
> i
(【LET】 ((*PACKAGE #<PACKAGE IMAGE-BASED-COMMON-LISP-USER>)) (PRINT (QUOTE HELLO)))
> n
(LET 【((*PACKAGE #<PACKAGE IMAGE-BASED-COMMON-LISP-USER>))】 (PRINT (QUOTE HELLO)))
> i
(LET (【(*PACKAGE #<PACKAGE IMAGE-BASED-COMMON-LISP-USER>)】) (PRINT (QUOTE HELLO)))
> i
(LET ((【*PACKAGE】 #<PACKAGE IMAGE-BASED-COMMON-LISP-USER>)) (PRINT (QUOTE HELLO)))
> r
replacement sexp: *package*
(LET ((【*PACKAGE*】 #<PACKAGE IMAGE-BASED-COMMON-LISP-USER>)) (PRINT (QUOTE HELLO)))
> q
(LET ((*PACKAGE* #<PACKAGE IMAGE-BASED-COMMON-LISP-USER>)) (PRINT 'HELLO))
C/IBCL-USER[5]> (eval *)

HELLO
HELLO
C/IBCL-USER[6]>

  


| Mirror on informatimago.com | Mirror on free.fr |
Valid HTML 4.01!