*** empty log message ***
This commit is contained in:
@ -1,7 +1,98 @@
|
||||
#include <xp/lisp/lisp.h>
|
||||
#include <xp/c/stdio.h>
|
||||
|
||||
int xp_main ()
|
||||
#ifdef LINUX
|
||||
#include <mcheck.h>
|
||||
#endif
|
||||
|
||||
static int get_char (xp_lisp_cint* ch, void* arg)
|
||||
{
|
||||
xp_lisp_cint c;
|
||||
|
||||
c = fgetc(stdin);
|
||||
if (c == XP_EOF) {
|
||||
if (ferror(stdin)) return -1;
|
||||
c = XP_EOF;
|
||||
}
|
||||
|
||||
*ch = c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int to_int (const xp_char_t* str)
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
while (*str != XP_CHAR('\0')) {
|
||||
if (!xp_isdigit(*str)) break;
|
||||
r = r * 10 + (*str - XP_CHAR('0'));
|
||||
str++;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int xp_main (int argc, xp_char_t* argv[])
|
||||
{
|
||||
xp_lisp_t* lisp;
|
||||
xp_lisp_obj_t* obj;
|
||||
|
||||
#ifdef LINUX
|
||||
mtrace ();
|
||||
#endif
|
||||
if (argc != 3) {
|
||||
xp_fprintf (xp_stderr, XP_TEXT("usage: %s mem_ubound mem_ubound_inc\n"), argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
lisp = xp_lisp_new (to_int(argv[1]), to_int(argv[2]));
|
||||
if (lisp == NULL) {
|
||||
xp_fprintf (xp_stderr, XP_TEXT("can't create a lisp instance\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
xp_printf (XP_TEXT("LISP 0.0001\n"));
|
||||
|
||||
xp_lisp_set_creader (lisp, get_char, NULL);
|
||||
|
||||
for (;;) {
|
||||
xp_printf (XP_TEXT("%s> "), argv[0]);
|
||||
|
||||
obj = xp_lisp_read (lisp);
|
||||
if (obj == NULL) {
|
||||
if (lisp->error != XP_LISP_ERR_END &&
|
||||
lisp->error != XP_LISP_ERR_ABORT) {
|
||||
xp_fprintf (xp_stderr,
|
||||
XP_TEXT("error while reading: %d\n"), lisp->error);
|
||||
}
|
||||
|
||||
if (lisp->error < XP_LISP_ERR_SYNTAX) break;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((obj = xp_lisp_eval (lisp, obj)) != NULL) {
|
||||
xp_lisp_print (lisp, obj);
|
||||
xp_printf (XP_TEXT("\n"));
|
||||
}
|
||||
else {
|
||||
if (lisp->error == XP_LISP_ERR_ABORT) break;
|
||||
xp_fprintf (xp_stderr,
|
||||
XP_TEXT("error while reading: %d\n"), lisp->error);
|
||||
}
|
||||
|
||||
/*
|
||||
printf ("-----------\n");
|
||||
xp_lisp_print (lisp, obj);
|
||||
printf ("\n-----------\n");
|
||||
*/
|
||||
}
|
||||
|
||||
xp_lisp_free (lisp);
|
||||
|
||||
#ifdef LINUX
|
||||
muntrace ();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,8 +3,8 @@ OUTS = $(SRCS:.c=.x)
|
||||
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@ -I@abs_top_builddir@
|
||||
LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/xp/c
|
||||
LIBS = @LIBS@ -lxpc
|
||||
LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/xp/c -L@abs_top_builddir@/xp/lisp
|
||||
LIBS = @LIBS@ -lxpc -lxplisp
|
||||
|
||||
all: $(OUTS)
|
||||
|
||||
|
16
ase/test/lsp/t1.lsp
Normal file
16
ase/test/lsp/t1.lsp
Normal file
@ -0,0 +1,16 @@
|
||||
(setq x (lambda (x) (car x)))
|
||||
((lambda (x) (+ x 99)) (x '(10 20 30)))
|
||||
|
||||
((lambda (x) ((lambda (y) (+ y 1)) x)) 10)
|
||||
; lisp....
|
||||
((lambda (x) ((macro (y) (+ y 1)) x)) 10)
|
||||
|
||||
|
||||
|
||||
|
||||
;;;;;;;
|
||||
(setq init-rand (macro (seed) (lambda () (setq seed (+ seed 1)))))
|
||||
(setq init-rand (lambda (seed) (lambda () (setq seed (+ seed 1)))))
|
||||
(setq rand (init-rand 1))
|
||||
(rand)
|
||||
|
169
ase/test/lsp/t2.lsp
Normal file
169
ase/test/lsp/t2.lsp
Normal file
@ -0,0 +1,169 @@
|
||||
(setq x (lambda (x) (+ x 20 30 40)))
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 100)
|
||||
(x 200)
|
||||
(x 200)
|
||||
(x 200)
|
||||
(x 200)
|
||||
(x 200)
|
Reference in New Issue
Block a user