From 4f9c21e00b32944618251098a027281d6c5d3235 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 18 Sep 2005 11:54:23 +0000 Subject: [PATCH] *** empty log message *** --- ase/lsp/env.h | 4 +-- ase/lsp/lsp.h | 4 +-- ase/lsp/mem.h | 4 +-- ase/lsp/{object.h => obj.h} | 6 ++-- ase/test/lsp/lisp.c | 55 +++++++++++++++++++++++++++---------- 5 files changed, 50 insertions(+), 23 deletions(-) rename ase/lsp/{object.h => obj.h} (96%) diff --git a/ase/lsp/env.h b/ase/lsp/env.h index ce30191b..b1959ebb 100644 --- a/ase/lsp/env.h +++ b/ase/lsp/env.h @@ -1,11 +1,11 @@ /* - * $Id: env.h,v 1.5 2005-09-18 11:34:35 bacon Exp $ + * $Id: env.h,v 1.6 2005-09-18 11:54:23 bacon Exp $ */ #ifndef _XP_LSP_ENV_H_ #define _XP_LSP_ENV_H_ -#include +#include struct xp_lsp_assoc_t { diff --git a/ase/lsp/lsp.h b/ase/lsp/lsp.h index ab3151aa..0083ed99 100644 --- a/ase/lsp/lsp.h +++ b/ase/lsp/lsp.h @@ -1,5 +1,5 @@ /* - * $Id: lsp.h,v 1.7 2005-09-18 11:34:35 bacon Exp $ + * $Id: lsp.h,v 1.8 2005-09-18 11:54:23 bacon Exp $ */ #ifndef _XP_LSP_LSP_H_ @@ -14,7 +14,7 @@ #include #include -#include +#include #include #define XP_LSP_ERR(lsp) ((lsp)->errnum) diff --git a/ase/lsp/mem.h b/ase/lsp/mem.h index a93fa84d..27776ee4 100644 --- a/ase/lsp/mem.h +++ b/ase/lsp/mem.h @@ -1,11 +1,11 @@ /* - * $Id: mem.h,v 1.1 2005-09-18 11:34:35 bacon Exp $ + * $Id: mem.h,v 1.2 2005-09-18 11:54:23 bacon Exp $ */ #ifndef _XP_LSP_MEM_H_ #define _XP_LSP_MEM_H_ -#include +#include #include #include diff --git a/ase/lsp/object.h b/ase/lsp/obj.h similarity index 96% rename from ase/lsp/object.h rename to ase/lsp/obj.h index 6c6d458d..46d5050d 100644 --- a/ase/lsp/object.h +++ b/ase/lsp/obj.h @@ -1,9 +1,9 @@ /* - * $Id: object.h,v 1.6 2005-09-18 08:10:50 bacon Exp $ + * $Id: obj.h,v 1.1 2005-09-18 11:54:23 bacon Exp $ */ -#ifndef _XP_LSP_OBJECT_H_ -#define _XP_LSP_OBJECT_H_ +#ifndef _XP_LSP_OBJ_H_ +#define _XP_LSP_OBJ_H_ #include diff --git a/ase/test/lsp/lisp.c b/ase/test/lsp/lisp.c index edefc5b2..52c7faea 100644 --- a/ase/test/lsp/lisp.c +++ b/ase/test/lsp/lisp.c @@ -8,20 +8,51 @@ #include #endif -static int get_char (xp_cint_t* ch, void* arg) +static int get_char (int cmd, void* owner, void* arg) { xp_cint_t c; - - c = xp_fgetc(xp_stdin); - if (c == XP_CHAR_EOF) { - if (xp_ferror(xp_stdin)) return -1; - c = XP_CHAR_EOF; + + switch (cmd) { + case XP_LSP_IO_OPEN: + case XP_LSP_IO_CLOSE: + return 0; + + case XP_LSP_IO_CHAR: + c = xp_fgetc (xp_stdin); + if (c == XP_CHAR_EOF) { + if (xp_ferror(xp_stdin)) return -1; + } + + break; + + case XP_LSP_IO_STR: + return -1; } - *ch = c; return 0; } +static int put_char (int cmd, void* owner, void* arg) +{ + + switch (cmd) { + case XP_LSP_IO_OPEN: + case XP_LSP_IO_CLOSE: + return 0; + + case XP_LSP_IO_CHAR: + xp_fputc (*(xp_char_t*)arg, xp_stdout); + break; + + case XP_LSP_IO_STR: + xp_fputs ((xp_char_t*)arg, xp_stdout); + break; + } + + return 0; +} + + int to_int (const xp_char_t* str) { int r = 0; @@ -64,6 +95,7 @@ int handle_cli_error ( return -1; } + xp_cli_t* parse_cli (int argc, xp_char_t* argv[]) { static const xp_char_t* optsta[] = @@ -128,6 +160,7 @@ int xp_main (int argc, xp_char_t* argv[]) xp_printf (XP_TEXT("LSP 0.0001\n")); xp_lsp_attach_input (lsp, get_char); + xp_lsp_attach_output (lsp, put_char); for (;;) { xp_printf (XP_TEXT("%s> "), argv[0]); @@ -151,14 +184,8 @@ int xp_main (int argc, xp_char_t* argv[]) else { if (lsp->errnum == XP_LSP_ERR_ABORT) break; xp_fprintf (xp_stderr, - XP_TEXT("error while reading: %d\n"), lsp->errnum); + XP_TEXT("error while evaluating: %d\n"), lsp->errnum); } - - /* - printf ("-----------\n"); - xp_lsp_print (lsp, obj); - printf ("\n-----------\n"); - */ } xp_lsp_close (lsp);