*** empty log message ***

This commit is contained in:
hyung-hwan 2005-07-12 16:16:42 +00:00
parent bed09f1147
commit d92291a5f6
6 changed files with 108 additions and 21 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: bootstrp.c,v 1.24 2005-07-11 13:41:59 bacon Exp $
* $Id: bootstrp.c,v 1.25 2005-07-12 16:16:42 bacon Exp $
*/
#include <xp/stx/bootstrp.h>
@ -143,6 +143,38 @@ static class_info_t class_info[] =
XP_NULL,
XP_STX_SPEC_NOT_INDEXABLE
},
{
XP_TEXT("Number"),
XP_TEXT("Magnitude"),
XP_NULL,
XP_NULL,
XP_NULL,
XP_STX_SPEC_NOT_INDEXABLE
},
{
XP_TEXT("Integer"),
XP_TEXT("Number"),
XP_NULL,
XP_NULL,
XP_NULL,
XP_STX_SPEC_NOT_INDEXABLE
},
{
XP_TEXT("SmallInteger"),
XP_TEXT("Integer"),
XP_NULL,
XP_NULL,
XP_NULL,
XP_STX_SPEC_NOT_INDEXABLE
},
{
XP_TEXT("LargeInteger"),
XP_TEXT("Integer"),
XP_NULL,
XP_NULL,
XP_NULL,
XP_STX_SPEC_BYTE_INDEXABLE
},
{
XP_TEXT("Collection"),
XP_TEXT("Magnitude"),
@ -289,6 +321,7 @@ int xp_stx_bootstrap (xp_stx_t* stx)
stx->class_character = xp_stx_new_class (stx, XP_TEXT("Character"));
stx->class_dictionary = xp_stx_new_class (stx, XP_TEXT("Dictionary"));
stx->class_method = xp_stx_new_class (stx, XP_TEXT("Method"));
stx->class_smallinteger = xp_stx_new_class (stx, XP_TEXT("SmallInteger"));
__create_builtin_classes (stx);

View File

@ -1,5 +1,5 @@
/*
* $Id: name.c,v 1.1 2005-06-12 16:22:03 bacon Exp $
* $Id: name.c,v 1.2 2005-07-12 16:16:42 bacon Exp $
*/
#include <xp/stx/name.h>
@ -31,11 +31,6 @@ xp_stx_name_t* xp_stx_name_open (
}
}
/*
name->ivalue = 0;
name->fvalue = .0;
*/
name->size = 0;
name->capacity = capacity;
name->buffer[0] = XP_CHAR('\0');

View File

@ -1,5 +1,5 @@
/*
* $Id: parser.c,v 1.63 2005-07-11 13:41:59 bacon Exp $
* $Id: parser.c,v 1.64 2005-07-12 16:16:42 bacon Exp $
*/
#include <xp/stx/parser.h>
@ -380,16 +380,67 @@ static INLINE int __emit_do_primitive (xp_stx_parser_t* parser, int no)
return 0;
}
static INLINE int __add_literal (xp_stx_parser_t* parser, xp_word_t literal)
static int __add_literal (xp_stx_parser_t* parser, xp_word_t literal)
{
xp_word_t i;
for (i = 0; i < parser->literal_count; i++) {
/*
* it would remove redundancy of symbols and small integers.
* more complex redundacy check may be done somewhere else
* like in __add_string_literal.
*/
if (parser->literals[i] == literal) return i;
}
if (parser->literal_count >= xp_countof(parser->literals)) {
parser->error_code = XP_STX_PARSER_ERROR_TOO_MANY_LITERALS;
return -1;
}
parser->literals[parser->literal_count++] = literal;
return parser->literal_count - 1;
}
static int __add_character_literal (xp_stx_parser_t* parser, xp_char_t ch)
{
xp_word_t i, c, literal;
xp_stx_t* stx = parser->stx;
for (i = 0; i < parser->literal_count; i++) {
c = XP_STX_IS_SMALLINT(parser->literals[i])?
stx->class_smallinteger: XP_STX_CLASS (stx, parser->literals[i]);
if (c != stx->class_character) continue;
if (ch == XP_STX_CHARAT(stx,parser->literals[i],0)) return i;
}
literal = xp_stx_instantiate (
stx, stx->class_character, &ch, XP_NULL, 0);
return __add_literal (parser, literal);
}
static int __add_string_literal (
xp_stx_parser_t* parser, const xp_char_t* str, xp_word_t size)
{
xp_word_t i, c, literal;
xp_stx_t* stx = parser->stx;
for (i = 0; i < parser->literal_count; i++) {
c = XP_STX_IS_SMALLINT(parser->literals[i])?
stx->class_smallinteger: XP_STX_CLASS (stx, parser->literals[i]);
if (c != stx->class_string) continue;
if (xp_strxncmp (str, size,
XP_STX_DATA(stx,parser->literals[i]),
XP_STX_SIZE(stx,parser->literals[i])) == 0) return i;
}
literal = xp_stx_instantiate (
stx, stx->class_string, XP_NULL, str, size);
return __add_literal (parser, literal);
}
int xp_stx_parser_parse_method (
xp_stx_parser_t* parser, xp_word_t method_class, void* input)
{
@ -876,25 +927,27 @@ static int __parse_primary (xp_stx_parser_t* parser, const xp_char_t* ident)
GET_TOKEN (parser);
}
else if (parser->token.type == XP_STX_TOKEN_CHARLIT) {
literal = xp_stx_instantiate (
stx, stx->class_character,
parser->token.name.buffer, XP_NULL, 0);
pos = __add_literal(parser, literal);
pos = __add_character_literal(
parser, parser->token.name.buffer[0]);
if (pos == -1) return -1;
EMIT_PUSH_LITERAL_CONSTANT (parser, pos);
GET_TOKEN (parser);
}
else if (parser->token.type == XP_STX_TOKEN_STRLIT) {
literal = xp_stx_instantiate (
stx, stx->class_string, XP_NULL,
pos = __add_string_literal (parser,
parser->token.name.buffer, parser->token.name.size);
pos = __add_literal(parser, literal);
if (pos == -1) return -1;
EMIT_PUSH_LITERAL_CONSTANT (parser, pos);
GET_TOKEN (parser);
}
else if (parser->token.type == XP_STX_TOKEN_NUMLIT) {
EMIT_CODE_TEST (parser, XP_TEXT("PushLiteral(NUM)"), parser->token.name.buffer);
/* TODO: other types of numbers, negative numbers, etc */
xp_word_t tmp;
XP_STRTOI (tmp, parser->token.name.buffer, XP_NULL, 10);
literal = XP_STX_TO_SMALLINT(tmp);
pos = __add_literal(parser, literal);
if (pos == -1) return -1;
EMIT_PUSH_LITERAL_CONSTANT (parser, pos);
GET_TOKEN (parser);
}
else if (parser->token.type == XP_STX_TOKEN_SYMLIT) {

View File

@ -1,5 +1,5 @@
/*
* $Id: stx.c,v 1.32 2005-07-05 09:02:13 bacon Exp $
* $Id: stx.c,v 1.33 2005-07-12 16:16:42 bacon Exp $
*/
#include <xp/stx/stx.h>
@ -39,6 +39,7 @@ xp_stx_t* xp_stx_open (xp_stx_t* stx, xp_word_t capacity)
stx->class_string = XP_STX_NIL;
stx->class_dictionary = XP_STX_NIL;
stx->class_method = XP_STX_NIL;
stx->class_smallinteger = XP_STX_NIL;
stx->__wantabort = xp_false;
return stx;

View File

@ -1,5 +1,5 @@
/*
* $Id: stx.h,v 1.35 2005-07-11 13:41:59 bacon Exp $
* $Id: stx.h,v 1.36 2005-07-12 16:16:42 bacon Exp $
*/
#ifndef _XP_STX_STX_H_
@ -81,6 +81,7 @@ struct xp_stx_t
xp_word_t class_character;
xp_word_t class_dictionary;
xp_word_t class_method;
xp_word_t class_smallinteger;
xp_bool_t __malloced;
xp_bool_t __wantabort; /* TODO: make it a function pointer */

View File

@ -8,10 +8,14 @@ perform: method with: x with: y with: z with: a1 with: b2 with: c2
a := 'this is ''good'.
a := #xxx niceMethod.
"
b := -30 xxx nil this.
b := 12345 xxx nil this.
b := 30 + 20.
b := 'zzzzzz' xxx: 'cccccc' xy zzzz: 30 ccc:10.
b := 'zzzzzz' xxx: 'cccccc' xy zzzz: 30 ccc:10 ccc: 'cccccc'.
$3 asString.
$4 asString.
$4 asString.
$5 asString.
$5 asString.
selector := 20.
"