diff --git a/ase/stx/kernel/Object.st b/ase/stx/kernel/Object.st index aa20f0ff..d1304d8f 100644 --- a/ase/stx/kernel/Object.st +++ b/ase/stx/kernel/Object.st @@ -1,4 +1,4 @@ -!Objects methods! +!Object methods! = aValue ^ self == aValue diff --git a/ase/stx/lexer.c b/ase/stx/lexer.c new file mode 100644 index 00000000..1254e331 --- /dev/null +++ b/ase/stx/lexer.c @@ -0,0 +1,37 @@ +/* + * $Id + */ + +#include +#include +#include + +xp_stx_lexer_t* xp_stx_lexer_open (xp_stx_lexer_t* lexer) +{ + if (lexer == XP_NULL) { + lexer = (xp_stx_lexer_t*) + xp_stx_malloc (xp_sizeof(xp_stx_lexer_t)); + if (lexer == XP_NULL) return XP_NULL; + lexer->__malloced = xp_true; + } + else lexer->__malloced = xp_false; + + if (xp_stx_token_open (&lexer->token, 256) == XP_NULL) { + if (lexer->__malloced) xp_stx_free (lexer); + return XP_NULL; + } + + return lexer; +}; + +void xp_stx_lexer_close (xp_stx_lexer_t* lexer) +{ + xp_stx_token_close (&lexer->token); + if (lexer->__malloced) xp_stx_free (lexer); +} + +xp_stx_token_t* xp_stx_lexer_consume (xp_stx_lexer_t* lexer) +{ + /* TODO */ + return &lexer->token; +} diff --git a/ase/stx/lexer.h b/ase/stx/lexer.h new file mode 100644 index 00000000..c08a39ca --- /dev/null +++ b/ase/stx/lexer.h @@ -0,0 +1,31 @@ +/* + * $Id: lexer.h,v 1.1 2005-05-30 15:24:12 bacon Exp $ + */ + +#ifndef _XP_STX_LEXER_H_ +#define _XP_STX_LEXER_H_ + +#include +#include + +struct xp_stx_lexer_t +{ + xp_stx_token_t token; + xp_bool_t __malloced; +}; + +typedef struct xp_stx_lexer_t xp_stx_lexer_t; + +#ifdef __cplusplus +extern "C" { +#endif + +xp_stx_lexer_t* xp_stx_lexer_open (xp_stx_lexer_t* lexer); +void xp_stx_lexer_close (xp_stx_lexer_t* lexer); +xp_stx_token_t* xp_stx_lexer_consume (xp_stx_lexer_t* lexer); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ase/stx/makefile.lcc b/ase/stx/makefile.lcc index 09560e88..1ef1b2c5 100644 --- a/ase/stx/makefile.lcc +++ b/ase/stx/makefile.lcc @@ -1,7 +1,7 @@ SRCS = stx.c memory.c object.c symbol.c class.c \ - hash.c misc.c context.c token.c parser.c bootstrp.c + hash.c misc.c context.c token.c lexer.c parser.c bootstrp.c OBJS = stx.obj memory.obj object.obj symbol.obj class.obj \ - hash.obj misc.obj context.obj token.obj parser.obj bootstrp.obj + hash.obj misc.obj context.obj token.obj lexer.obj parser.obj bootstrp.obj OUT = xpstx.lib CC = lcc diff --git a/ase/stx/parser.c b/ase/stx/parser.c index 199829be..68c6be17 100644 --- a/ase/stx/parser.c +++ b/ase/stx/parser.c @@ -1,5 +1,5 @@ /* - * $Id: parser.c,v 1.6 2005-05-30 07:38:25 bacon Exp $ + * $Id: parser.c,v 1.7 2005-05-30 15:24:12 bacon Exp $ */ #include @@ -15,11 +15,31 @@ xp_stx_parser_t* xp_stx_parser_open (xp_stx_parser_t* parser) } else parser->__malloced = xp_false; + if (xp_stx_lexer_open (&parser->lexer) == XP_NULL) { + if (parser->__malloced) xp_stx_free (parser); + return XP_NULL; + } + + parser->token = XP_NULL; + parser->error_code = 0; return parser; } void xp_stx_parser_close (xp_stx_parser_t* parser) { + xp_stx_lexer_close (&parser->lexer); if (parser->__malloced) xp_stx_free (parser); } +int xp_stx_parser_parse (xp_stx_parser_t* parser) +{ + parser->token = xp_stx_lexer_consume (&parser->lexer); + if (parser->token == XP_NULL) { + /*parser->error_code = xxx;*/ + return -1; + } + + return 0; +} + + diff --git a/ase/stx/parser.h b/ase/stx/parser.h index 38957711..f4faf74d 100644 --- a/ase/stx/parser.h +++ b/ase/stx/parser.h @@ -1,15 +1,19 @@ /* - * $Id: parser.h,v 1.4 2005-05-30 07:38:25 bacon Exp $ + * $Id: parser.h,v 1.5 2005-05-30 15:24:12 bacon Exp $ */ #ifndef _XP_STX_PARSER_H_ #define _XP_STX_PARSER_H_ #include -#include +#include +#include struct xp_stx_parser_t { + xp_stx_lexer_t lexer; + xp_stx_token_t* token; + int error_code; xp_bool_t __malloced; }; diff --git a/ase/stx/scanner.c b/ase/stx/scanner.c deleted file mode 100644 index 2728dbdb..00000000 --- a/ase/stx/scanner.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * $Id - */ - -#include - -xp_stx_scanner_t* xp_stx_scanner_open (xp_stx_scanner_t* scanner) -{ - if (scanner == XP_NULL) { - scanner = (xp_stx_scanner_t*) - xp_stx_malloc (xp_sizeof(xp_stx_scanner_t)); - if (scanner == XP_NULL) return XP_NULL; - scanner->__malloced = xp_true; - } - else scanner->__malloced = xp_false; - - if (xp_stx_token_open (&scanner->token) == XP_NULL) { - if (scanner->__malloced) xp_stx_free (scanner); - return XP_NULL; - } - - return scanner; -}; - -void xp_stx_scanner_close (xp_stx_scanner_t* scanner) -{ - xp_stx_token_close (&scanner->token); - if (scanner->__malloced) xp_stx_free (scanner); -} - diff --git a/ase/stx/scanner.h b/ase/stx/scanner.h deleted file mode 100644 index 9c5e5b43..00000000 --- a/ase/stx/scanner.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * $Id: scanner.h,v 1.3 2005-05-22 15:03:20 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 -} -#endif - -#endif