*** empty log message ***

This commit is contained in:
hyung-hwan 2006-10-23 14:57:44 +00:00
parent 0d5283e988
commit a079b79fd9
9 changed files with 86 additions and 64 deletions

View File

@ -1,10 +1,8 @@
/* /*
* $Id: array.c,v 1.9 2006-10-23 10:57:59 bacon Exp $ * $Id: array.c,v 1.10 2006-10-23 14:49:16 bacon Exp $
*/ */
#include <sse/lsp/array.h> #include <sse/lsp/lsp_i.h>
#include <sse/bas/memory.h>
#include <sse/bas/assert.h>
sse_lsp_array_t* sse_lsp_array_new (sse_size_t capacity) sse_lsp_array_t* sse_lsp_array_new (sse_size_t capacity)
{ {

View File

@ -103,7 +103,7 @@ SOURCE=.\eval.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\init.c SOURCE=.\lsp.c
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -111,6 +111,10 @@ SOURCE=.\mem.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\misc.c
# End Source File
# Begin Source File
SOURCE=.\name.c SOURCE=.\name.c
# End Source File # End Source File
# Begin Source File # Begin Source File
@ -167,6 +171,10 @@ SOURCE=.\mem.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\misc.h
# End Source File
# Begin Source File
SOURCE=.\name.h SOURCE=.\name.h
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -1,12 +1,11 @@
/* /*
* $Id: lsp.h,v 1.23 2006-10-23 14:42:38 bacon Exp $ * $Id: lsp.h,v 1.24 2006-10-23 14:57:44 bacon Exp $
*/ */
#ifndef _SSE_LSP_LSP_H_ #ifndef _SSE_LSP_LSP_H_
#define _SSE_LSP_LSP_H_ #define _SSE_LSP_LSP_H_
#include <sse/types.h> #include <sse/lsp/types.h>
#include <sse/macros.h>
typedef struct sse_lsp_t sse_lsp_t; typedef struct sse_lsp_t sse_lsp_t;
typedef struct sse_lsp_obj_t sse_lsp_obj_t; typedef struct sse_lsp_obj_t sse_lsp_obj_t;

22
ase/lsp/makefile.bcc Normal file
View File

@ -0,0 +1,22 @@
SRCS = lsp.c name.c token.c array.c mem.c env.c err.c \
read.c eval.c print.c \
prim.c prim_prog.c prim_let.c prim_compar.c prim_math.c
OBJS = $(SRCS:.c=.obj)
OUT = sselsp.lib
CC = bcc32
CFLAGS = -O2 -WM -w -w-inl -w-sig -w-spa -w-hid -RT- -I../..
all: $(OBJS)
tlib $(OUT) @&&!
+-$(**: = &^
+-)
!
clean:
-del $(OBJS) $(OUT) *.obj
.SUFFIXES: .c .obj
.c.obj:
$(CC) $(CFLAGS) -c $<

View File

@ -2,7 +2,7 @@ SRCS = lsp.c name.c token.c array.c mem.c env.c err.c \
read.c eval.c print.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 = sselsp.lib
CC = cl CC = cl
LD = link LD = link

View File

@ -1,6 +1,6 @@
SRCS = name.c token.c array.c prim.c mem.c env.c init.c read.c eval.c print.c SRCS = name.c token.c array.c prim.c mem.c env.c init.c read.c eval.c print.c
OBJS = name.obj token.obj array.obj prim.obj mem.obj env.obj init.obj read.obj eval.obj print.obj OBJS = name.obj token.obj array.obj prim.obj mem.obj env.obj init.obj read.obj eval.obj print.obj
OUT = xpstx.lib OUT = sselsp.lib
CC = lcc CC = lcc
CFLAGS = -I../.. -A -ansic -libcdll CFLAGS = -I../.. -A -ansic -libcdll

View File

@ -1,13 +1,8 @@
/* /*
* $Id: mem.c,v 1.10 2006-10-23 14:44:43 bacon Exp $ * $Id: mem.c,v 1.11 2006-10-23 14:49:16 bacon Exp $
*/ */
#include <sse/lsp/mem.h> #include <sse/lsp/lsp_i.h>
#include <sse/lsp/prim.h>
#include <sse/bas/memory.h>
#include <sse/bas/string.h>
#include <sse/bas/assert.h>
sse_lsp_mem_t* sse_lsp_mem_new (sse_size_t ubound, sse_size_t ubound_inc) sse_lsp_mem_t* sse_lsp_mem_new (sse_size_t ubound, sse_size_t ubound_inc)
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: read.c,v 1.18 2006-10-22 13:10:46 bacon Exp $ * $Id: read.c,v 1.19 2006-10-23 14:44:43 bacon Exp $
*/ */
#include <sse/lsp/lsp.h> #include <sse/lsp/lsp.h>
@ -13,12 +13,12 @@
#define IS_ALNUM(x) sse_isalnum(x) #define IS_ALNUM(x) sse_isalnum(x)
#define IS_IDENT(c) \ #define IS_IDENT(c) \
((c) == SSE_CHAR('+') || (c) == SSE_CHAR('-') || \ ((c) == SSE_T('+') || (c) == SSE_T('-') || \
(c) == SSE_CHAR('*') || (c) == SSE_CHAR('/') || \ (c) == SSE_T('*') || (c) == SSE_T('/') || \
(c) == SSE_CHAR('%') || (c) == SSE_CHAR('&') || \ (c) == SSE_T('%') || (c) == SSE_T('&') || \
(c) == SSE_CHAR('<') || (c) == SSE_CHAR('>') || \ (c) == SSE_T('<') || (c) == SSE_T('>') || \
(c) == SSE_CHAR('=') || (c) == SSE_CHAR('_') || \ (c) == SSE_T('=') || (c) == SSE_T('_') || \
(c) == SSE_CHAR('?')) (c) == SSE_T('?'))
#define TOKEN_CLEAR(lsp) sse_lsp_token_clear (&(lsp)->token) #define TOKEN_CLEAR(lsp) sse_lsp_token_clear (&(lsp)->token)
#define TOKEN_TYPE(lsp) (lsp)->token.type #define TOKEN_TYPE(lsp) (lsp)->token.type
@ -66,7 +66,7 @@ static int read_string (sse_lsp_t* lsp);
sse_lsp_obj_t* sse_lsp_read (sse_lsp_t* lsp) sse_lsp_obj_t* sse_lsp_read (sse_lsp_t* lsp)
{ {
if (lsp->curc == SSE_CHAR_EOF && if (lsp->curc == SSE_T_EOF &&
read_char(lsp) == -1) return SSE_NULL; read_char(lsp) == -1) return SSE_NULL;
lsp->errnum = SSE_LSP_ERR_NONE; lsp->errnum = SSE_LSP_ERR_NONE;
@ -112,8 +112,8 @@ static sse_lsp_obj_t* read_obj (sse_lsp_t* lsp)
return obj; return obj;
case TOKEN_IDENT: case TOKEN_IDENT:
sse_assert (lsp->mem->nil != SSE_NULL && lsp->mem->t != SSE_NULL); sse_assert (lsp->mem->nil != SSE_NULL && lsp->mem->t != SSE_NULL);
if (TOKEN_COMPARE(lsp,SSE_TEXT("nil")) == 0) obj = lsp->mem->nil; if (TOKEN_COMPARE(lsp,SSE_T("nil")) == 0) obj = lsp->mem->nil;
else if (TOKEN_COMPARE(lsp,SSE_TEXT("t")) == 0) obj = lsp->mem->t; else if (TOKEN_COMPARE(lsp,SSE_T("t")) == 0) obj = lsp->mem->t;
else { else {
obj = sse_lsp_make_symbolx ( obj = sse_lsp_make_symbolx (
lsp->mem, TOKEN_SVALUE(lsp), TOKEN_SLENGTH(lsp)); lsp->mem, TOKEN_SVALUE(lsp), TOKEN_SLENGTH(lsp));
@ -238,7 +238,7 @@ static int read_char (sse_lsp_t* lsp)
return -1; return -1;
} }
if (n == 0) lsp->curc = SSE_CHAR_EOF; if (n == 0) lsp->curc = SSE_T_EOF;
return 0; return 0;
} }
@ -253,43 +253,43 @@ static int read_token (sse_lsp_t* lsp)
while (IS_SPACE(lsp->curc)) NEXT_CHAR (lsp); while (IS_SPACE(lsp->curc)) NEXT_CHAR (lsp);
// skip the comments here // skip the comments here
if (lsp->curc == SSE_CHAR(';')) { if (lsp->curc == SSE_T(';')) {
do { do {
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
} while (lsp->curc != SSE_CHAR('\n') && lsp->curc != SSE_CHAR_EOF); } while (lsp->curc != SSE_T('\n') && lsp->curc != SSE_T_EOF);
} }
else break; else break;
} }
if (lsp->curc == SSE_CHAR_EOF) { if (lsp->curc == SSE_T_EOF) {
TOKEN_TYPE(lsp) = TOKEN_END; TOKEN_TYPE(lsp) = TOKEN_END;
return 0; return 0;
} }
else if (lsp->curc == SSE_CHAR('(')) { else if (lsp->curc == SSE_T('(')) {
TOKEN_ADD_CHAR (lsp, lsp->curc); TOKEN_ADD_CHAR (lsp, lsp->curc);
TOKEN_TYPE(lsp) = TOKEN_LPAREN; TOKEN_TYPE(lsp) = TOKEN_LPAREN;
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
return 0; return 0;
} }
else if (lsp->curc == SSE_CHAR(')')) { else if (lsp->curc == SSE_T(')')) {
TOKEN_ADD_CHAR (lsp, lsp->curc); TOKEN_ADD_CHAR (lsp, lsp->curc);
TOKEN_TYPE(lsp) = TOKEN_RPAREN; TOKEN_TYPE(lsp) = TOKEN_RPAREN;
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
return 0; return 0;
} }
else if (lsp->curc == SSE_CHAR('\'')) { else if (lsp->curc == SSE_T('\'')) {
TOKEN_ADD_CHAR (lsp, lsp->curc); TOKEN_ADD_CHAR (lsp, lsp->curc);
TOKEN_TYPE(lsp) = TOKEN_QUOTE; TOKEN_TYPE(lsp) = TOKEN_QUOTE;
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
return 0; return 0;
} }
else if (lsp->curc == SSE_CHAR('.')) { else if (lsp->curc == SSE_T('.')) {
TOKEN_ADD_CHAR (lsp, lsp->curc); TOKEN_ADD_CHAR (lsp, lsp->curc);
TOKEN_TYPE(lsp) = TOKEN_DOT; TOKEN_TYPE(lsp) = TOKEN_DOT;
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
return 0; return 0;
} }
else if (lsp->curc == SSE_CHAR('-')) { else if (lsp->curc == SSE_T('-')) {
TOKEN_ADD_CHAR (lsp, lsp->curc); TOKEN_ADD_CHAR (lsp, lsp->curc);
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
if (IS_DIGIT(lsp->curc)) { if (IS_DIGIT(lsp->curc)) {
@ -309,7 +309,7 @@ static int read_token (sse_lsp_t* lsp)
else if (IS_ALPHA(lsp->curc) || IS_IDENT(lsp->curc)) { else if (IS_ALPHA(lsp->curc) || IS_IDENT(lsp->curc)) {
return read_ident (lsp); return read_ident (lsp);
} }
else if (lsp->curc == SSE_CHAR('\"')) { else if (lsp->curc == SSE_T('\"')) {
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
return read_string (lsp); return read_string (lsp);
} }
@ -325,20 +325,20 @@ static int read_number (sse_lsp_t* lsp, int negative)
sse_lsp_real_t rvalue = 0.; sse_lsp_real_t rvalue = 0.;
do { do {
ivalue = ivalue * 10 + (lsp->curc - SSE_CHAR('0')); ivalue = ivalue * 10 + (lsp->curc - SSE_T('0'));
TOKEN_ADD_CHAR (lsp, lsp->curc); TOKEN_ADD_CHAR (lsp, lsp->curc);
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
} while (IS_DIGIT(lsp->curc)); } while (IS_DIGIT(lsp->curc));
/* TODO: extend parsing floating point number */ /* TODO: extend parsing floating point number */
if (lsp->curc == SSE_CHAR('.')) { if (lsp->curc == SSE_T('.')) {
sse_lsp_real_t fraction = 0.1; sse_lsp_real_t fraction = 0.1;
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
rvalue = (sse_lsp_real_t)ivalue; rvalue = (sse_lsp_real_t)ivalue;
while (IS_DIGIT(lsp->curc)) { while (IS_DIGIT(lsp->curc)) {
rvalue += (sse_lsp_real_t)(lsp->curc - SSE_CHAR('0')) * fraction; rvalue += (sse_lsp_real_t)(lsp->curc - SSE_T('0')) * fraction;
fraction *= 0.1; fraction *= 0.1;
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
} }
@ -372,7 +372,7 @@ static int read_string (sse_lsp_t* lsp)
sse_cint_t code = 0; sse_cint_t code = 0;
do { do {
if (lsp->curc == SSE_CHAR_EOF) { if (lsp->curc == SSE_T_EOF) {
TOKEN_TYPE(lsp) = TOKEN_UNTERM_STRING; TOKEN_TYPE(lsp) = TOKEN_UNTERM_STRING;
return 0; return 0;
} }
@ -386,34 +386,34 @@ static int read_string (sse_lsp_t* lsp)
} }
else if (escaped == 1) { else if (escaped == 1) {
/* backslash + character */ /* backslash + character */
if (lsp->curc == SSE_CHAR('a')) if (lsp->curc == SSE_T('a'))
lsp->curc = SSE_CHAR('\a'); lsp->curc = SSE_T('\a');
else if (lsp->curc == SSE_CHAR('b')) else if (lsp->curc == SSE_T('b'))
lsp->curc = SSE_CHAR('\b'); lsp->curc = SSE_T('\b');
else if (lsp->curc == SSE_CHAR('f')) else if (lsp->curc == SSE_T('f'))
lsp->curc = SSE_CHAR('\f'); lsp->curc = SSE_T('\f');
else if (lsp->curc == SSE_CHAR('n')) else if (lsp->curc == SSE_T('n'))
lsp->curc = SSE_CHAR('\n'); lsp->curc = SSE_T('\n');
else if (lsp->curc == SSE_CHAR('r')) else if (lsp->curc == SSE_T('r'))
lsp->curc = SSE_CHAR('\r'); lsp->curc = SSE_T('\r');
else if (lsp->curc == SSE_CHAR('t')) else if (lsp->curc == SSE_T('t'))
lsp->curc = SSE_CHAR('\t'); lsp->curc = SSE_T('\t');
else if (lsp->curc == SSE_CHAR('v')) else if (lsp->curc == SSE_T('v'))
lsp->curc = SSE_CHAR('\v'); lsp->curc = SSE_T('\v');
else if (lsp->curc == SSE_CHAR('0')) { else if (lsp->curc == SSE_T('0')) {
escaped = 2; escaped = 2;
code = 0; code = 0;
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
continue; continue;
} }
else if (lsp->curc == SSE_CHAR('x')) { else if (lsp->curc == SSE_T('x')) {
escaped = 3; escaped = 3;
code = 0; code = 0;
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
continue; continue;
} }
} }
else if (lsp->curc == SSE_CHAR('\\')) { else if (lsp->curc == SSE_T('\\')) {
escaped = 1; escaped = 1;
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
continue; continue;
@ -421,7 +421,7 @@ static int read_string (sse_lsp_t* lsp)
TOKEN_ADD_CHAR (lsp, lsp->curc); TOKEN_ADD_CHAR (lsp, lsp->curc);
NEXT_CHAR (lsp); NEXT_CHAR (lsp);
} while (lsp->curc != SSE_CHAR('\"')); } while (lsp->curc != SSE_T('\"'));
TOKEN_TYPE(lsp) = TOKEN_STRING; TOKEN_TYPE(lsp) = TOKEN_STRING;
NEXT_CHAR (lsp); NEXT_CHAR (lsp);

View File

@ -1,14 +1,14 @@
/* /*
* $Id: token.c,v 1.13 2006-10-22 13:10:46 bacon Exp $ * $Id: token.c,v 1.14 2006-10-23 14:49:16 bacon Exp $
*/ */
#include <sse/lsp/token.h> #include <sse/lsp/lsp_i.h>
#include <sse/bas/memory.h>
sse_lsp_token_t* sse_lsp_token_open ( sse_lsp_token_t* sse_lsp_token_open (
sse_lsp_token_t* token, sse_word_t capacity) sse_lsp_token_t* token, sse_word_t capacity)
{ {
if (token == SSE_NULL) { if (token == SSE_NULL)
{
token = (sse_lsp_token_t*) token = (sse_lsp_token_t*)
sse_malloc (sse_sizeof(sse_lsp_token_t)); sse_malloc (sse_sizeof(sse_lsp_token_t));
if (token == SSE_NULL) return SSE_NULL; if (token == SSE_NULL) return SSE_NULL;