diff --git a/ase/lsp/array.c b/ase/lsp/array.c index 52ee8277..c2960d59 100644 --- a/ase/lsp/array.c +++ b/ase/lsp/array.c @@ -1,5 +1,5 @@ /* - * $Id: array.c,v 1.4 2005-04-24 07:48:16 bacon Exp $ + * $Id: array.c,v 1.5 2005-05-22 13:41:14 bacon Exp $ */ #include @@ -86,7 +86,7 @@ void xp_lisp_array_clear (xp_lisp_array_t* array) array->buffer[0] = XP_NULL; } -void** xp_lisp_array_transfer (xp_lisp_array_t* array, xp_size_t capacity) +void** xp_lisp_array_yield (xp_lisp_array_t* array, xp_size_t capacity) { void** old_buffer, ** new_buffer; diff --git a/ase/lsp/array.h b/ase/lsp/array.h index f777b399..2b5e37ac 100644 --- a/ase/lsp/array.h +++ b/ase/lsp/array.h @@ -1,5 +1,5 @@ /* - * $Id: array.h,v 1.2 2005-02-04 16:00:37 bacon Exp $ + * $Id: array.h,v 1.3 2005-05-22 13:41:14 bacon Exp $ */ #ifndef _XP_LISP_ARRAY_H_ @@ -25,7 +25,7 @@ int xp_lisp_array_add_item (xp_lisp_array_t* array, void* item); int xp_lisp_array_insert (xp_lisp_array_t* array, xp_size_t index, void* value); void xp_lisp_array_delete (xp_lisp_array_t* array, xp_size_t index); void xp_lisp_array_clear (xp_lisp_array_t* array); -void** xp_lisp_array_transfer (xp_lisp_array_t* array, xp_size_t capacity); +void** xp_lisp_array_yield (xp_lisp_array_t* array, xp_size_t capacity); #ifdef __cplusplus } diff --git a/ase/lsp/token.c b/ase/lsp/token.c index dcec2fec..710643bc 100644 --- a/ase/lsp/token.c +++ b/ase/lsp/token.c @@ -1,5 +1,5 @@ /* - * $Id: token.c,v 1.8 2005-04-24 07:48:16 bacon Exp $ + * $Id: token.c,v 1.9 2005-05-22 13:41:14 bacon Exp $ */ #include @@ -12,10 +12,10 @@ xp_lisp_token_t* xp_lisp_token_new (xp_size_t capacity) xp_assert (capacity > 0); - token = (xp_lisp_token_t*)xp_malloc (sizeof(xp_lisp_token_t)); + token = (xp_lisp_token_t*)xp_malloc (xp_sizeof(xp_lisp_token_t)); if (token == XP_NULL) return XP_NULL; - token->buffer = (xp_char_t*)xp_malloc ((capacity + 1) * sizeof(xp_char_t)); + token->buffer = (xp_char_t*)xp_malloc ((capacity + 1) * xp_sizeof(xp_char_t)); if (token->buffer == XP_NULL) { xp_free (token); return XP_NULL; @@ -41,8 +41,8 @@ int xp_lisp_token_addc (xp_lisp_token_t* token, xp_cint_t c) { if (token->size >= token->capacity) { // double the capacity. - xp_char_t* new_buffer = (xp_char_t*)realloc ( - token->buffer, (token->capacity * 2 + 1) * sizeof(xp_char_t)); + xp_char_t* new_buffer = (xp_char_t*)xp_realloc ( + token->buffer, (token->capacity * 2 + 1) * xp_sizeof(xp_char_t)); if (new_buffer == XP_NULL) return -1; token->buffer = new_buffer; token->capacity = token->capacity * 2; @@ -62,11 +62,11 @@ void xp_lisp_token_clear (xp_lisp_token_t* token) token->buffer[0] = XP_CHAR('\0'); } -xp_char_t* xp_lisp_token_transfer (xp_lisp_token_t* token, xp_size_t capacity) +xp_char_t* xp_lisp_token_yield (xp_lisp_token_t* token, xp_size_t capacity) { xp_char_t* old_buffer, * new_buffer; - new_buffer = (xp_char_t*)xp_malloc((capacity + 1) * sizeof(xp_char_t)); + new_buffer = (xp_char_t*)xp_malloc((capacity + 1) * xp_sizeof(xp_char_t)); if (new_buffer == XP_NULL) return XP_NULL; old_buffer = token->buffer; diff --git a/ase/lsp/token.h b/ase/lsp/token.h index 3a384668..49908a2d 100644 --- a/ase/lsp/token.h +++ b/ase/lsp/token.h @@ -1,5 +1,5 @@ /* - * $Id: token.h,v 1.5 2005-02-14 14:37:50 bacon Exp $ + * $Id: token.h,v 1.6 2005-05-22 13:41:14 bacon Exp $ */ #ifndef _XP_LISP_TOKEN_H_ @@ -25,12 +25,12 @@ typedef struct xp_lisp_token_t xp_lisp_token_t; extern "C" { #endif -xp_lisp_token_t* xp_lisp_token_new (xp_size_t capacity); -void xp_lisp_token_free (xp_lisp_token_t* token); -int xp_lisp_token_addc (xp_lisp_token_t* token, xp_cint_t c); -void xp_lisp_token_clear (xp_lisp_token_t* token); -xp_char_t* xp_lisp_token_transfer (xp_lisp_token_t* token, xp_size_t capacity); -int xp_lisp_token_compare (xp_lisp_token_t* token, const xp_char_t* str); +xp_lisp_token_t* xp_lisp_token_new (xp_size_t capacity); +void xp_lisp_token_free (xp_lisp_token_t* token); +int xp_lisp_token_addc (xp_lisp_token_t* token, xp_cint_t c); +void xp_lisp_token_clear (xp_lisp_token_t* token); +xp_char_t* xp_lisp_token_yield (xp_lisp_token_t* token, xp_size_t capacity); +int xp_lisp_token_compare (xp_lisp_token_t* token, const xp_char_t* str); #ifdef __cplusplus } diff --git a/ase/stx/makefile.lcc b/ase/stx/makefile.lcc index a389591c..fa738e1e 100644 --- a/ase/stx/makefile.lcc +++ b/ase/stx/makefile.lcc @@ -1,5 +1,5 @@ -SRCS = stx.c memory.c object.c symbol.c hash.c misc.c context.c -OBJS = stx.obj memory.obj object.obj symbol.obj hash.obj misc.obj context.obj +SRCS = stx.c memory.c object.c symbol.c hash.c misc.c context.c token.c +OBJS = stx.obj memory.obj object.obj symbol.obj hash.obj misc.obj context.obj token.obj OUT = xpstx.lib CC = lcc diff --git a/ase/stx/scanner.c b/ase/stx/scanner.c new file mode 100644 index 00000000..a6f7c1c7 --- /dev/null +++ b/ase/stx/scanner.c @@ -0,0 +1,5 @@ +/* + * $Id + */ + +#include diff --git a/ase/stx/scanner.h b/ase/stx/scanner.h index 17bd4e1b..f8c9f6f8 100644 --- a/ase/stx/scanner.h +++ b/ase/stx/scanner.h @@ -1,16 +1,27 @@ /* - * $Id: scanner.h,v 1.1 2005-05-22 04:11:54 bacon Exp $ + * $Id: scanner.h,v 1.2 2005-05-22 13:41:14 bacon Exp $ */ #ifndef _XP_STX_SCANNER_H_ #define _XP_STX_SCANNER_H_ #include +#include + +struct xp_stx_scanner_t +{ + xp_stx_token_t token; + xp_bool_t __malloced; +}; + +typedef struct xp_stx_scanner_t xp_stx_scanner_t; #ifdef __cplusplus extern "C" { #endif +xp_stx_scanner_t* xp_stx_scanner_open (xp_stx_scanner_t* scanner); +void xp_stx_scanner_close (xp_stx_scanner_t* scanner): #ifdef __cplusplus } diff --git a/ase/stx/stx.h b/ase/stx/stx.h index 6de50250..781267bf 100644 --- a/ase/stx/stx.h +++ b/ase/stx/stx.h @@ -1,5 +1,5 @@ /* - * $Id: stx.h,v 1.18 2005-05-22 04:34:22 bacon Exp $ + * $Id: stx.h,v 1.19 2005-05-22 13:41:14 bacon Exp $ */ #ifndef _XP_STX_STX_H_ @@ -10,9 +10,8 @@ typedef xp_byte_t xp_stx_byte_t; typedef xp_char_t xp_stx_char_t; +typedef xp_cint_t xp_stx_cint_t; typedef xp_size_t xp_stx_word_t; -typedef xp_size_t xp_stx_size_t; -typedef xp_size_t xp_stx_index_t; typedef struct xp_stx_objhdr_t xp_stx_objhdr_t; typedef struct xp_stx_object_t xp_stx_object_t; diff --git a/ase/stx/token.c b/ase/stx/token.c index 436e8c57..72541ed9 100644 --- a/ase/stx/token.c +++ b/ase/stx/token.c @@ -1,5 +1,5 @@ /* - * $Id: token.c,v 1.1 2005-05-22 10:32:37 bacon Exp $ + * $Id: token.c,v 1.2 2005-05-22 13:41:14 bacon Exp $ */ #include @@ -12,14 +12,14 @@ xp_stx_token_t* xp_stx_token_new ( if (token == XP_NULL) { token = (xp_stx_token_t*) - xp_stx_malloc (sizeof(xp_stx_token_t)); + xp_stx_malloc (xp_sizeof(xp_stx_token_t)); if (token == XP_NULL) return XP_NULL; token->__malloced = xp_true; } else token->__malloced = xp_false; - token->buffer = (xp_char_t*) - xp_stx_malloc ((capacity + 1) * sizeof(xp_char_t)); + token->buffer = (xp_stx_char_t*) + xp_stx_malloc ((capacity + 1) * xp_sizeof(xp_stx_char_t)); if (token->buffer == XP_NULL) { if (token->__malloced) xp_stx_free (token); return XP_NULL; @@ -43,14 +43,14 @@ void xp_stx_token_close (xp_stx_token_t* token) if (token->__malloced) xp_stx_free (token); } -int xp_stx_token_addc (xp_stx_token_t* token, xp_cint_t c) +int xp_stx_token_addc (xp_stx_token_t* token, xp_stx_cint_t c) { if (token->size >= token->capacity) { // double the capacity. - xp_char_t* new_buffer = (xp_char_t*)realloc ( - token->buffer, (token->capacity * 2 + 1) * sizeof(xp_char_t)); - if (new_buffer == XP_NULL) return -1; - token->buffer = new_buffer; + xp_stx_char_t* space = (xp_stx_char_t*)xp_stx_realloc ( + token->buffer, (token->capacity * 2 + 1) * xp_sizeof(xp_stx_char_t)); + if (space == XP_NULL) return -1; + token->buffer = space; token->capacity = token->capacity * 2; } @@ -61,18 +61,21 @@ int xp_stx_token_addc (xp_stx_token_t* token, xp_cint_t c) void xp_stx_token_clear (xp_stx_token_t* token) { + /* token->ivalue = 0; token->fvalue = .0; + */ token->size = 0; token->buffer[0] = XP_STX_CHAR('\0'); } -xp_char_t* xp_stx_token_transfer (xp_stx_token_t* token, xp_size_t capacity) +xp_stx_char_t* xp_stx_token_yield (xp_stx_token_t* token, xp_stx_word_t capacity) { - xp_char_t* old_buffer, * new_buffer; + xp_stx_char_t* old_buffer, * new_buffer; - new_buffer = (xp_char_t*)xp_malloc((capacity + 1) * sizeof(xp_char_t)); + new_buffer = (xp_stx_char_t*) + xp_stx_malloc((capacity + 1) * xp_sizeof(xp_stx_char_t)); if (new_buffer == XP_NULL) return XP_NULL; old_buffer = token->buffer; @@ -84,10 +87,10 @@ xp_char_t* xp_stx_token_transfer (xp_stx_token_t* token, xp_size_t capacity) return old_buffer; } -int xp_stx_token_compare (xp_stx_token_t* token, const xp_char_t* str) +int xp_stx_token_compare (xp_stx_token_t* token, const xp_stx_char_t* str) { - xp_char_t* p = token->buffer; - xp_size_t index = 0; + xp_stx_char_t* p = token->buffer; + xp_stx_word_t index = 0; while (index < token->size) { if (*p > *str) return 1; diff --git a/ase/stx/token.h b/ase/stx/token.h index 03e472f1..15a9e55d 100644 --- a/ase/stx/token.h +++ b/ase/stx/token.h @@ -1,5 +1,5 @@ /* - * $Id: token.h,v 1.1 2005-05-22 10:32:37 bacon Exp $ + * $Id: token.h,v 1.2 2005-05-22 13:41:14 bacon Exp $ */ #ifndef _XP_STX_TOKEN_H_ @@ -16,9 +16,9 @@ struct xp_stx_token_t xp_stx_real_t fvalue; */ - xp_size_t capacity; - xp_size_t size; - xp_char_t* buffer; + xp_stx_word_t capacity; + xp_stx_word_t size; + xp_stx_char_t* buffer; xp_bool_t __malloced; }; @@ -33,10 +33,10 @@ xp_stx_token_t* xp_stx_token_open ( xp_stx_token_t* token, xp_stx_word_t capacity); void xp_stx_token_close (xp_stx_token_t* token); -int xp_stx_token_addc (xp_stx_token_t* token, xp_cint_t c); -void xp_stx_token_clear (xp_stx_token_t* token); -xp_char_t* xp_stx_token_transfer (xp_stx_token_t* token, xp_size_t capacity); -int xp_stx_token_compare (xp_stx_token_t* token, const xp_char_t* str); +int xp_stx_token_addc (xp_stx_token_t* token, xp_stx_cint_t c); +void xp_stx_token_clear (xp_stx_token_t* token); +xp_stx_char_t* xp_stx_token_yield (xp_stx_token_t* token, xp_stx_word_t capacity); +int xp_stx_token_compare (xp_stx_token_t* token, const xp_stx_char_t* str); #ifdef __cplusplus }