*** empty log message ***

This commit is contained in:
hyung-hwan 2005-05-30 15:27:31 +00:00
parent 390d3c4c61
commit 4ff42a06f0
8 changed files with 98 additions and 66 deletions

View File

@ -1,4 +1,4 @@
!Objects methods!
!Object methods!
= aValue
^ self == aValue

37
ase/stx/lexer.c Normal file
View File

@ -0,0 +1,37 @@
/*
* $Id
*/
#include <xp/stx/lexer.h>
#include <xp/stx/parser.h>
#include <xp/stx/misc.h>
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;
}

31
ase/stx/lexer.h Normal file
View File

@ -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 <xp/stx/stx.h>
#include <xp/stx/token.h>
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

View File

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

View File

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

View File

@ -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 <xp/stx/stx.h>
#include <xp/stx/scanner.h>
#include <xp/stx/lexer.h>
#include <xp/stx/token.h>
struct xp_stx_parser_t
{
xp_stx_lexer_t lexer;
xp_stx_token_t* token;
int error_code;
xp_bool_t __malloced;
};

View File

@ -1,30 +0,0 @@
/*
* $Id
*/
#include <xp/stx/scanner.h>
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);
}

View File

@ -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 <xp/stx/stx.h>
#include <xp/stx/token.h>
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