*** empty log message ***

This commit is contained in:
hyung-hwan 2005-06-06 16:04:18 +00:00
parent 5242c8900a
commit 54c381b87f
4 changed files with 35 additions and 22 deletions

View File

@ -1,9 +1,9 @@
/* /*
* $Id: read.c,v 1.9 2005-05-30 07:15:35 bacon Exp $ * $Id: read.c,v 1.10 2005-06-06 16:04:18 bacon Exp $
*/ */
#include <xp/lisp/lisp.h> #include <xp/lsp/lisp.h>
#include <xp/lisp/token.h> #include <xp/lsp/token.h>
#include <xp/bas/assert.h> #include <xp/bas/assert.h>
#include <xp/bas/ctype.h> #include <xp/bas/ctype.h>

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parser.c,v 1.16 2005-06-06 15:46:48 bacon Exp $ * $Id: parser.c,v 1.17 2005-06-06 16:01:49 bacon Exp $
*/ */
#include <xp/stx/parser.h> #include <xp/stx/parser.h>
@ -58,6 +58,13 @@ void xp_stx_parser_close (xp_stx_parser_t* parser)
do { if (__unget_char(parser,c) == -1) return -1; } while (0) do { if (__unget_char(parser,c) == -1) return -1; } while (0)
#define GET_TOKEN(parser) \ #define GET_TOKEN(parser) \
do { if (__get_token(parser) == -1) return -1; } while (0) do { if (__get_token(parser) == -1) return -1; } while (0)
#define ADD_TOKEN_CHAR(parser,c) \
do { \
if (xp_stx_token_addc (&(parser)->token, c) == -1) { \
(parser)->error_code = XP_STX_PARSER_ERROR_MEMORY; \
return -1; \
} \
} while (0)
int xp_stx_parser_parse_method ( int xp_stx_parser_parse_method (
xp_stx_parser_t* parser, xp_stx_word_t method_class, void* input) xp_stx_parser_t* parser, xp_stx_word_t method_class, void* input)
@ -88,6 +95,11 @@ static int __parse_method (
static int __parse_message_pattern (xp_stx_parser_t* parser) static int __parse_message_pattern (xp_stx_parser_t* parser)
{ {
while (parser->token.type != XP_STX_TOKEN_END) {
xp_printf (XP_TEXT("token: [%s] %d\n"),
parser->token.buffer, parser->token.type);
GET_TOKEN (parser);
}
return 0; return 0;
} }
@ -107,7 +119,11 @@ static int __get_token (xp_stx_parser_t* parser)
c = parser->curc; c = parser->curc;
xp_stx_token_clear (&parser->token); xp_stx_token_clear (&parser->token);
if (xp_stx_isalpha(c)) { xp_printf (XP_TEXT("xxxxxxxxxx[%d][%d]xxx\n"), c, XP_STX_CHAR_EOF);
if (c == XP_STX_CHAR_EOF) {
parser->token.type = XP_STX_TOKEN_END;
}
else if (xp_stx_isalpha(c)) {
if (__get_ident(parser) == -1) return -1; if (__get_ident(parser) == -1) return -1;
} }
else if (xp_stx_isdigit(c)) { else if (xp_stx_isdigit(c)) {
@ -118,6 +134,11 @@ static int __get_token (xp_stx_parser_t* parser)
else if (c == XP_STX_CHAR('\'')) { else if (c == XP_STX_CHAR('\'')) {
if (__get_strlit(parser) == -1) return -1; if (__get_strlit(parser) == -1) return -1;
} }
else if (c == XP_STX_CHAR('^')) {
parser->token.type = XP_STX_TOKEN_RETURN;
ADD_TOKEN_CHAR(parser, c);
GET_CHAR (parser);
}
else { else {
parser->error_code = XP_STX_PARSER_ERROR_CHAR; parser->error_code = XP_STX_PARSER_ERROR_CHAR;
return -1; return -1;
@ -137,10 +158,7 @@ static int __get_ident (xp_stx_parser_t* parser)
parser->token.type = XP_STX_TOKEN_IDENT; parser->token.type = XP_STX_TOKEN_IDENT;
do { do {
if (xp_stx_token_addc (&parser->token, c) == -1) { ADD_TOKEN_CHAR(parser, c);
parser->error_code = XP_STX_PARSER_ERROR_MEMORY;
return -1;
}
GET_CHAR (parser); GET_CHAR (parser);
c = parser->curc; c = parser->curc;
} while (xp_stx_isalnum(c)); } while (xp_stx_isalnum(c));
@ -167,11 +185,7 @@ static int __get_charlit (xp_stx_parser_t* parser)
} }
parser->token.type = XP_STX_TOKEN_CHARLIT; parser->token.type = XP_STX_TOKEN_CHARLIT;
if (xp_stx_token_addc (&parser->token, c) == -1) { ADD_TOKEN_CHAR(parser, c);
parser->error_code = XP_STX_PARSER_ERROR_MEMORY;
return -1;
}
GET_CHAR (parser); GET_CHAR (parser);
return 0; return 0;
} }
@ -191,10 +205,7 @@ static int __get_strlit (xp_stx_parser_t* parser)
do { do {
do { do {
if (xp_stx_token_addc (&parser->token, c) == -1) { ADD_TOKEN_CHAR (parser, c);
parser->error_code = XP_STX_PARSER_ERROR_MEMORY;
return -1;
}
GET_CHAR (parser); GET_CHAR (parser);
c = parser->curc; c = parser->curc;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: token.h,v 1.4 2005-06-05 16:44:05 bacon Exp $ * $Id: token.h,v 1.5 2005-06-06 16:01:49 bacon Exp $
*/ */
#ifndef _XP_STX_TOKEN_H_ #ifndef _XP_STX_TOKEN_H_
@ -13,7 +13,8 @@ enum
XP_STX_TOKEN_CHARLIT, XP_STX_TOKEN_CHARLIT,
XP_STX_TOKEN_STRLIT, XP_STX_TOKEN_STRLIT,
XP_STX_TOKEN_IDENT, XP_STX_TOKEN_IDENT,
XP_STX_TOKEN_KEYWORD XP_STX_TOKEN_KEYWORD,
XP_STX_TOKEN_RETURN
}; };
struct xp_stx_token_t struct xp_stx_token_t

View File

@ -75,8 +75,9 @@ int stdio_func (int cmd, void* owner, void* arg)
else if (cmd == XP_STX_PARSER_INPUT_CONSUME) { else if (cmd == XP_STX_PARSER_INPUT_CONSUME) {
stdio_t* p = (stdio_t*)owner; stdio_t* p = (stdio_t*)owner;
xp_cint_t* c = (xp_cint_t*)arg; xp_cint_t* c = (xp_cint_t*)arg;
xp_cint_t t = xp_fgetc (p->stdio); xp_cint_t t = (xp_cint_t)xp_fgetc (p->stdio);
if (t == EOF) { xp_printf (XP_TEXT("*c -> %d %d %d\n"), t, XP_CHAR_EOF, EOF);
if (t == XP_CHAR_EOF) {
if (xp_ferror (p->stdio)) return -1; if (xp_ferror (p->stdio)) return -1;
*c = XP_STX_CHAR_EOF; *c = XP_STX_CHAR_EOF;
} }