*** empty log message ***

This commit is contained in:
hyung-hwan 2005-05-22 13:41:14 +00:00
parent 450c413990
commit 0bf97fb3bd
10 changed files with 65 additions and 47 deletions

View File

@ -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 <xp/lisp/array.h>
@ -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;

View File

@ -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
}

View File

@ -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 <xp/lisp/token.h>
@ -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;

View File

@ -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_
@ -29,7 +29,7 @@ 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);
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

View File

@ -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

5
ase/stx/scanner.c Normal file
View File

@ -0,0 +1,5 @@
/*
* $Id
*/
#include <xp/stx/scanner.h>

View File

@ -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 <xp/stx/stx.h>
#include <xp/stx/token.h>
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
}

View File

@ -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;

View File

@ -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 <xp/stx/token.h>
@ -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;

View File

@ -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);
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_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);
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
}