*** empty log message ***

This commit is contained in:
hyung-hwan 2006-10-23 10:57:59 +00:00
parent 75c2b15b8a
commit 4d0847c229
7 changed files with 68 additions and 146 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: array.c,v 1.8 2006-10-22 13:10:45 bacon Exp $ * $Id: array.c,v 1.9 2006-10-23 10:57:59 bacon Exp $
*/ */
#include <sse/lsp/array.h> #include <sse/lsp/array.h>
@ -11,10 +11,10 @@ sse_lsp_array_t* sse_lsp_array_new (sse_size_t capacity)
sse_lsp_array_t* array; sse_lsp_array_t* array;
sse_assert (capacity > 0); sse_assert (capacity > 0);
array = (sse_lsp_array_t*)malloc (sizeof(sse_lsp_array_t)); array = (sse_lsp_array_t*) sse_malloc (sizeof(sse_lsp_array_t));
if (array == SSE_NULL) return SSE_NULL; if (array == SSE_NULL) return SSE_NULL;
array->buffer = (void**)malloc (capacity + 1); array->buffer = (void**) sse_malloc (capacity + 1);
if (array->buffer == SSE_NULL) { if (array->buffer == SSE_NULL) {
free (array); free (array);
return SSE_NULL; return SSE_NULL;
@ -90,7 +90,7 @@ void** sse_lsp_array_yield (sse_lsp_array_t* array, sse_size_t capacity)
{ {
void** old_buffer, ** new_buffer; void** old_buffer, ** new_buffer;
new_buffer = (void**)malloc(capacity + 1); new_buffer = (void**) sse_malloc (capacity + 1);
if (new_buffer == SSE_NULL) return SSE_NULL; if (new_buffer == SSE_NULL) return SSE_NULL;
old_buffer = array->buffer; old_buffer = array->buffer;

45
ase/lsp/err.c Normal file
View File

@ -0,0 +1,45 @@
/*
* $Id: err.c,v 1.1 2006-10-23 10:54:15 bacon Exp $
*/
#include <sse/lsp/lsp.h>
static const sse_char_t* __errstr[] =
{
SSE_T("no error"),
SSE_T("abort"),
SSE_T("end"),
SSE_T("memory"),
SSE_T("input not attached"),
SSE_T("input"),
SSE_T("output not attached"),
SSE_T("output"),
SSE_T("syntax"),
SSE_T("bad arguments"),
SSE_T("wrong arguments"),
SSE_T("too few arguments"),
SSE_T("too many arguments"),
SSE_T("undefined function"),
SSE_T("bad function"),
SSE_T("duplicate formal"),
SSE_T("bad symbol"),
SSE_T("undefined symbol"),
SSE_T("empty body"),
SSE_T("bad value"),
SSE_T("divide by zero")
};
int sse_lsp_geterrnum (sse_lsp_t* lsp)
{
return lsp->errnum;
}
const sse_char_t* sse_lsp_geterrstr (int errnum)
{
if (errnum >= 0 && errnum < sse_countof(__errstr))
{
return __errstr[errnum];
}
return SSE_T("unknown error");
}

View File

@ -1,39 +0,0 @@
/*
* $Id: error.c,v 1.3 2006-10-22 13:10:45 bacon Exp $
*/
#include <sse/lsp/lsp.h>
#include <sse/bas/string.h>
static const sse_char_t* __errstr[] =
{
SSE_TEXT("no error"),
SSE_TEXT("abort"),
SSE_TEXT("end"),
SSE_TEXT("memory"),
SSE_TEXT("input not attached"),
SSE_TEXT("input"),
SSE_TEXT("output not attached"),
SSE_TEXT("output"),
SSE_TEXT("syntax"),
SSE_TEXT("bad arguments"),
SSE_TEXT("wrong arguments"),
SSE_TEXT("too few arguments"),
SSE_TEXT("too many arguments"),
SSE_TEXT("undefined function"),
SSE_TEXT("bad function"),
SSE_TEXT("duplicate formal"),
SSE_TEXT("bad symbol"),
SSE_TEXT("undefined symbol"),
SSE_TEXT("empty body"),
SSE_TEXT("bad value"),
SSE_TEXT("divide by zero")
};
int sse_lsp_error (sse_lsp_t* lsp, sse_char_t* buf, sse_size_t size)
{
if (buf == SSE_NULL || size == 0) return lsp->errnum;
sse_strxcpy (buf, size, __errstr[lsp->errnum]);
return lsp->errnum;
}

View File

@ -42,7 +42,7 @@ RSC=rc.exe
# PROP Target_Dir "" # PROP Target_Dir ""
MTL=midl.exe MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "../.." /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@ -66,7 +66,7 @@ LIB32=link.exe -lib
# PROP Target_Dir "" # PROP Target_Dir ""
MTL=midl.exe MTL=midl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../.." /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe BSC32=bscmake.exe
@ -95,7 +95,7 @@ SOURCE=.\env.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\error.c SOURCE=.\err.c
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -1,5 +1,5 @@
/* /*
* $Id: lsp.h,v 1.21 2006-10-22 13:10:46 bacon Exp $ * $Id: lsp.h,v 1.22 2006-10-23 10:54:15 bacon Exp $
*/ */
#ifndef _SSE_LSP_LSP_H_ #ifndef _SSE_LSP_LSP_H_
@ -17,7 +17,6 @@
#include <sse/lsp/obj.h> #include <sse/lsp/obj.h>
#include <sse/lsp/mem.h> #include <sse/lsp/mem.h>
#define SSE_LSP_ERR(lsp) ((lsp)->errnum)
enum enum
{ {
SSE_LSP_ERR_NONE = 0, SSE_LSP_ERR_NONE = 0,
@ -63,10 +62,6 @@ enum
SSE_LSP_IO_DATA SSE_LSP_IO_DATA
}; };
/*
* TYPEDEF: sse_lsp_prim_t
* Defines a primitive type
*/
typedef sse_lsp_obj_t* (*sse_lsp_prim_t) (sse_lsp_t* lsp, sse_lsp_obj_t* obj); typedef sse_lsp_obj_t* (*sse_lsp_prim_t) (sse_lsp_t* lsp, sse_lsp_obj_t* obj);
struct sse_lsp_t struct sse_lsp_t
@ -98,108 +93,29 @@ struct sse_lsp_t
extern "C" { extern "C" {
#endif #endif
/* sse_lsp_t* sse_lsp_open (
* FUNCTION: sse_lsp_open sse_lsp_t* lsp, sse_size_t mem_ubound, sse_size_t mem_ubound_inc);
* Instantiates a lisp processor
*
* PARAMETERS:
* lsp - pointer to lisp processor space or SSE_NULL
* mem_ubound - memory upper bound
* mem_ubound_inc - memory increment
*/
sse_lsp_t* sse_lsp_open (sse_lsp_t* lsp,
sse_size_t mem_ubound, sse_size_t mem_ubound_inc);
/*
* FUNCTION: sse_lsp_close
* Destroys a lisp processor
*
* PARAMETERS:
* lsp - the pointer to the lisp object
*/
void sse_lsp_close (sse_lsp_t* lsp); void sse_lsp_close (sse_lsp_t* lsp);
/* int sse_lsp_geterrnum (sse_lsp_t* awk);
* FUNCTION: sse_lsp_error
*/
int sse_lsp_error (sse_lsp_t* lsp, sse_char_t* buf, sse_size_t size);
/*
* FUNCTION: sse_lsp_attach_input
* Attaches an input handler function
*
* PARAMETERS:
* lsp - the lisp processor
* input - input handler function
* arg - user data to be passed to the input handler
*
* RETURNS:
* 0 on success, -1 on failure
*/
int sse_lsp_attach_input (sse_lsp_t* lsp, sse_lsp_io_t input, void* arg); int sse_lsp_attach_input (sse_lsp_t* lsp, sse_lsp_io_t input, void* arg);
/*
* FUNCTION: sse_lsp_detach_input
* Detaches an input handler function
*
* RETURNS:
* 0 on success, -1 on failure
*/
int sse_lsp_detach_input (sse_lsp_t* lsp); int sse_lsp_detach_input (sse_lsp_t* lsp);
/*
* FUNCTION: sse_lsp_attach_output
* Attaches an output handler function
*
* PARAMETERS:
* lsp - the lisp processor
* output - output handler function
* arg - user data to be passed to the output handler
*
* RETURNS:
* 0 on success, -1 on failure
*/
int sse_lsp_attach_output (sse_lsp_t* lsp, sse_lsp_io_t output, void* arg); int sse_lsp_attach_output (sse_lsp_t* lsp, sse_lsp_io_t output, void* arg);
/*
* FUNCTION: sse_lsp_detach_output
* Detaches an output handler function
*
* RETURNS:
* 0 on success, -1 on failure
*/
int sse_lsp_detach_output (sse_lsp_t* lsp); int sse_lsp_detach_output (sse_lsp_t* lsp);
/*
* FUNCTION: sse_lsp_read
* Reads a lisp expression
*/
sse_lsp_obj_t* sse_lsp_read (sse_lsp_t* lsp); sse_lsp_obj_t* sse_lsp_read (sse_lsp_t* lsp);
/*
* FUNCTION: sse_lsp_eval
* Evaluates a lisp object
*/
sse_lsp_obj_t* sse_lsp_eval (sse_lsp_t* lsp, sse_lsp_obj_t* obj); sse_lsp_obj_t* sse_lsp_eval (sse_lsp_t* lsp, sse_lsp_obj_t* obj);
/*
* FUNCTION: sse_lsp_print
* Prints a lisp object
*/
int sse_lsp_print (sse_lsp_t* lsp, const sse_lsp_obj_t* obj); int sse_lsp_print (sse_lsp_t* lsp, const sse_lsp_obj_t* obj);
/*
* FUNCTION: sse_lsp_add_prim
* Adds a user-defined primitive
*/
int sse_lsp_add_prim (sse_lsp_t* lsp, const sse_char_t* name, sse_lsp_prim_t prim); int sse_lsp_add_prim (sse_lsp_t* lsp, const sse_char_t* name, sse_lsp_prim_t prim);
/*
* FUNCTION: sse_lsp_remove_prim
* Removes a user-defined primitive
*/
int sse_lsp_remove_prim (sse_lsp_t* lsp, const sse_char_t* name); int sse_lsp_remove_prim (sse_lsp_t* lsp, const sse_char_t* name);
const sse_char_t* sse_lsp_geterrstr (int errnum);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,18 +1,18 @@
SRCS = name.c token.c array.c mem.c env.c error.c \ SRCS = name.c token.c array.c mem.c env.c err.c \
init.c read.c eval.c print.c \ init.c read.c eval.c print.c \
prim.c prim_prog.c prim_let.c prim_compar.c prim_math.c prim.c prim_prog.c prim_let.c prim_compar.c prim_math.c
OBJS = $(SRCS:.c=.obj) OBJS = $(SRCS:.c=.obj)
OUT = xplsp.lib OUT = xplsp.lib
CC = cl CC = cl
CFLAGS = /nologo /MT /GX /W3 /GR- /D_WIN32_WINNT=0x0400 -I../.. LD = link
CFLAGS = /nologo /O2 /MT /W3 /GR- /Za -I../.. -DSSE_CHAR_IS_WCHAR
all: $(OBJS) all: $(OBJS)
link -lib @<< $(LD) -lib @<<
/nologo /out:$(OUT) $(OBJS) /nologo /out:$(OUT) $(OBJS)
<< <<
clean: clean:
del $(OBJS) $(OUT) *.obj del $(OBJS) $(OUT) *.obj

View File

@ -1,5 +1,5 @@
/* /*
* $Id: mem.c,v 1.8 2006-10-22 13:10:46 bacon Exp $ * $Id: mem.c,v 1.9 2006-10-23 10:57:59 bacon Exp $
*/ */
#include <sse/lsp/mem.h> #include <sse/lsp/mem.h>