From 0322d27e803b363741cddbf3b3ad79264cae6a8b Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 2 Jun 2005 16:14:58 +0000 Subject: [PATCH] *** empty log message *** --- ase/stx/lexer.c | 11 ++++++++++- ase/stx/lexer.h | 9 +++++++-- ase/stx/parser.c | 37 ++++++++++--------------------------- ase/stx/parser.h | 5 ++++- ase/stx/token.h | 14 +++++++++++++- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/ase/stx/lexer.c b/ase/stx/lexer.c index 1254e331..d8c9e100 100644 --- a/ase/stx/lexer.c +++ b/ase/stx/lexer.c @@ -6,7 +6,8 @@ #include #include -xp_stx_lexer_t* xp_stx_lexer_open (xp_stx_lexer_t* lexer) +xp_stx_lexer_t* xp_stx_lexer_open ( + xp_stx_lexer_t* lexer, const xp_stx_char_t* text) { if (lexer == XP_NULL) { lexer = (xp_stx_lexer_t*) @@ -21,6 +22,7 @@ xp_stx_lexer_t* xp_stx_lexer_open (xp_stx_lexer_t* lexer) return XP_NULL; } + lexer->text = text; return lexer; }; @@ -30,6 +32,13 @@ void xp_stx_lexer_close (xp_stx_lexer_t* lexer) if (lexer->__malloced) xp_stx_free (lexer); } +void xp_stx_lexer_reset ( + xp_stx_lexer_t* lexer, const xp_stx_char_t* text) +{ + xp_stx_token_clear (&lexer->token); + lexer->text = text; +} + xp_stx_token_t* xp_stx_lexer_consume (xp_stx_lexer_t* lexer) { /* TODO */ diff --git a/ase/stx/lexer.h b/ase/stx/lexer.h index c08a39ca..5715ae97 100644 --- a/ase/stx/lexer.h +++ b/ase/stx/lexer.h @@ -1,5 +1,5 @@ /* - * $Id: lexer.h,v 1.1 2005-05-30 15:24:12 bacon Exp $ + * $Id: lexer.h,v 1.2 2005-06-02 16:14:58 bacon Exp $ */ #ifndef _XP_STX_LEXER_H_ @@ -11,6 +11,7 @@ struct xp_stx_lexer_t { xp_stx_token_t token; + const xp_stx_char_t* text; xp_bool_t __malloced; }; @@ -20,8 +21,12 @@ typedef struct xp_stx_lexer_t xp_stx_lexer_t; extern "C" { #endif -xp_stx_lexer_t* xp_stx_lexer_open (xp_stx_lexer_t* lexer); +xp_stx_lexer_t* xp_stx_lexer_open ( + xp_stx_lexer_t* lexer, const xp_stx_char_t* text); void xp_stx_lexer_close (xp_stx_lexer_t* lexer); + +void xp_stx_lexer_reset ( + xp_stx_lexer_t* lexer, const xp_stx_char_t* text); xp_stx_token_t* xp_stx_lexer_consume (xp_stx_lexer_t* lexer); #ifdef __cplusplus diff --git a/ase/stx/parser.c b/ase/stx/parser.c index 78b65348..5c1fbcec 100644 --- a/ase/stx/parser.c +++ b/ase/stx/parser.c @@ -1,5 +1,5 @@ /* - * $Id: parser.c,v 1.8 2005-05-30 15:55:06 bacon Exp $ + * $Id: parser.c,v 1.9 2005-06-02 16:14:58 bacon Exp $ */ #include @@ -16,12 +16,12 @@ 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 (xp_stx_lexer_open (&parser->lexer, XP_NULL) == XP_NULL) { if (parser->__malloced) xp_stx_free (parser); return XP_NULL; } - parser->token = XP_NULL; + //parser->token = XP_NULL; parser->error_code = 0; return parser; } @@ -32,33 +32,16 @@ void xp_stx_parser_close (xp_stx_parser_t* parser) if (parser->__malloced) xp_stx_free (parser); } -/* set input stream */ -/* -int xp_stx_parser_set_ios (xp_stx_parser_t* parser, input_func) +int xp_stx_parser_parse_method (xp_stx_parser_t* parser, + xp_stx_word_t method_class, xp_stx_char_t* method_text) { -} + xp_stx_lexer_reset (&parser->lexer, method_text); -int xp_stx_parser_parse_filein (xp_stx_parser_t* parser) -{ - xp_stx_token_t* token; - - token = xp_stx_lexer_consume (&parser->lexer); - if (token == XP_NULL) return -1; - - if (token->type == XP_STX_TOKEN_EXCLM) -} -*/ - -int xp_stx_parser_parse_method ( - xp_stx_parser_t* parser, xp_stx_word_t class, xp_stx_char_t* text) -{ - xp_stx_lexer_reset (&parser->lexer, text); - - parser->token = xp_stx_lexer_consume (&parser->lexer); - if (parser->token == XP_NULL) { + //parser->token = xp_stx_lexer_consume (&parser->lexer); + //if (parser->token == XP_NULL) { /*parser->error_code = xxx;*/ - return -1; - } + // return -1; + //} return 0; } diff --git a/ase/stx/parser.h b/ase/stx/parser.h index cae534d3..34000c07 100644 --- a/ase/stx/parser.h +++ b/ase/stx/parser.h @@ -1,5 +1,5 @@ /* - * $Id: parser.h,v 1.6 2005-05-30 15:55:06 bacon Exp $ + * $Id: parser.h,v 1.7 2005-06-02 16:14:58 bacon Exp $ */ #ifndef _XP_STX_PARSER_H_ @@ -24,6 +24,9 @@ extern "C" { xp_stx_parser_t* xp_stx_parser_open (xp_stx_parser_t* parser); void xp_stx_parser_close (xp_stx_parser_t* parser); +int xp_stx_parse_method (xp_stx_parser_t* parser, + xp_stx_word_t method_class, xp_stx_char_t* method_text); + #ifdef __cplusplus } #endif diff --git a/ase/stx/token.h b/ase/stx/token.h index 15a9e55d..2cca34e6 100644 --- a/ase/stx/token.h +++ b/ase/stx/token.h @@ -1,5 +1,5 @@ /* - * $Id: token.h,v 1.2 2005-05-22 13:41:14 bacon Exp $ + * $Id: token.h,v 1.3 2005-06-02 16:14:58 bacon Exp $ */ #ifndef _XP_STX_TOKEN_H_ @@ -7,6 +7,18 @@ #include +enum +{ + XP_STX_TOKEN_END = 0, + XP_STX_TOKEN_STRING = 1, + XP_STX_TOKEN_IDENT = 2, + XP_STX_TOKEN_SELF = 3, + XP_STX_TOKEN_SUPER = 4, + XP_STX_TOKEN_NIL = 5, + XP_STX_TOKEN_TRUE = 6, + XP_STX_TOKEN_FALSE = 7 +}; + struct xp_stx_token_t { int type;