qse/ase/stx/parser.c

59 lines
1.3 KiB
C
Raw Normal View History

2005-05-12 15:51:20 +00:00
/*
2005-06-04 07:01:57 +00:00
* $Id: parser.c,v 1.10 2005-06-04 07:01:57 bacon Exp $
2005-05-12 15:51:20 +00:00
*/
#include <xp/stx/parser.h>
2005-05-30 15:55:06 +00:00
#include <xp/stx/token.h>
2005-05-22 04:11:54 +00:00
#include <xp/stx/misc.h>
xp_stx_parser_t* xp_stx_parser_open (xp_stx_parser_t* parser)
{
if (parser == XP_NULL) {
parser = (xp_stx_parser_t*)
xp_stx_malloc (xp_sizeof(xp_stx_parser_t));
if (parser == XP_NULL) return XP_NULL;
parser->__malloced = xp_true;
}
else parser->__malloced = xp_false;
2005-06-04 07:01:57 +00:00
if (xp_stx_token_open (&parser->token, 256) == XP_NULL) {
2005-05-30 15:27:31 +00:00
if (parser->__malloced) xp_stx_free (parser);
return XP_NULL;
}
parser->error_code = 0;
2005-06-04 07:01:57 +00:00
parser->text = XP_NULL;
parser->curc = XP_CHAR_EOF;
parser->curp = XP_NULL;
2005-05-22 04:11:54 +00:00
return parser;
}
void xp_stx_parser_close (xp_stx_parser_t* parser)
{
2005-06-04 07:01:57 +00:00
xp_stx_token_close (&parser->token);
2005-05-22 04:11:54 +00:00
if (parser->__malloced) xp_stx_free (parser);
}
2005-05-12 15:51:20 +00:00
2005-06-02 16:14:58 +00:00
int xp_stx_parser_parse_method (xp_stx_parser_t* parser,
xp_stx_word_t method_class, xp_stx_char_t* method_text)
2005-05-30 15:27:31 +00:00
{
2005-06-04 07:01:57 +00:00
/*xp_stx_lexer_reset (&parser->lexer, text);*/
2005-05-30 15:55:06 +00:00
2005-06-04 07:01:57 +00:00
#if 0
parser->token = xp_stx_lexer_consume (&parser->lexer);
if (parser->token == XP_NULL) {
2005-06-02 16:14:58 +00:00
//parser->token = xp_stx_lexer_consume (&parser->lexer);
//if (parser->token == XP_NULL) {
2005-05-30 15:27:31 +00:00
/*parser->error_code = xxx;*/
2005-06-04 07:01:57 +00:00
return -1;
}
#endif
2005-05-30 15:27:31 +00:00
return 0;
}
2005-06-04 07:01:57 +00:00
static int __get_token (xp_stx_parser_t* parser)
{
return -1;
}