*** empty log message ***

This commit is contained in:
hyung-hwan 2005-06-02 16:14:58 +00:00
parent 3dedd5d0e4
commit 0322d27e80
5 changed files with 44 additions and 32 deletions

View File

@ -6,7 +6,8 @@
#include <xp/stx/parser.h>
#include <xp/stx/misc.h>
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 */

View File

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

View File

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

View File

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

View File

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