diff --git a/ase/stx/parser.c b/ase/stx/parser.c index 30b0d3d7..ade9193f 100644 --- a/ase/stx/parser.c +++ b/ase/stx/parser.c @@ -1,5 +1,5 @@ /* - * $Id: parser.c,v 1.42 2005-06-28 15:23:58 bacon Exp $ + * $Id: parser.c,v 1.43 2005-06-29 10:56:42 bacon Exp $ */ #include @@ -22,6 +22,7 @@ static int __parse_keyword_pattern (xp_stx_parser_t* parser); static int __parse_temporaries (xp_stx_parser_t* parser); static int __parse_statements (xp_stx_parser_t* parser); +static int __parse_block_statements (xp_stx_parser_t* parser); static int __parse_statement (xp_stx_parser_t* parser); static int __parse_expression (xp_stx_parser_t* parser); @@ -253,6 +254,7 @@ static int __parse_method ( if (__parse_message_pattern(parser) == -1) return -1; if (__parse_temporaries(parser) == -1) return -1; if (__parse_statements(parser) == -1) return -1; + return 0; } @@ -445,6 +447,19 @@ static int __parse_statements (xp_stx_parser_t* parser) return 0; } +static int __parse_block_statements (xp_stx_parser_t* parser) +{ + while (parser->token.type != XP_STX_TOKEN_RBRACKET && + parser->token.type != XP_STX_TOKEN_END) { + + if (__parse_statement(parser) == -1) return -1; + if (parser->token.type != XP_STX_TOKEN_PERIOD) break; + GET_TOKEN (parser); + } + + return 0; +} + static int __parse_statement (xp_stx_parser_t* parser) { /* @@ -582,14 +597,14 @@ static int __parse_primary (xp_stx_parser_t* parser, const xp_char_t* ident) } else if (parser->token.type == XP_STX_TOKEN_LBRACKET) { GET_TOKEN (parser); - if (__parse_block_constructor (parser) == -1) return -1; + if (__parse_block_constructor(parser) == -1) return -1; } else if (parser->token.type == XP_STX_TOKEN_APAREN) { /* TODO: array literal */ } else if (parser->token.type == XP_STX_TOKEN_LPAREN) { GET_TOKEN (parser); - if (__parse_expression (parser) == -1) return -1; + if (__parse_expression(parser) == -1) return -1; if (parser->token.type != XP_STX_TOKEN_RPAREN) { parser->error_code = XP_STX_PARSER_ERROR_NO_RPAREN; return -1; @@ -620,6 +635,8 @@ static int __parse_block_constructor (xp_stx_parser_t* parser) if (parser->token.type == XP_STX_TOKEN_COLON) { do { + GET_TOKEN (parser); + if (parser->token.type != XP_STX_TOKEN_IDENT) { parser->error_code = XP_STX_PARSER_ERROR_BLOCK_ARGUMENT_NAME; return -1; @@ -638,8 +655,8 @@ static int __parse_block_constructor (xp_stx_parser_t* parser) } /* TODO: create a block closure */ - if (__parse_temporaries(parser/*, xp_true*/) == -1) return -1; - if (__parse_statements(parser/*, xp_true*/) == -1) return -1; + if (__parse_temporaries(parser) == -1) return -1; + if (__parse_block_statements(parser) == -1) return -1; if (parser->token.type != XP_STX_TOKEN_RBRACKET) { parser->error_code = XP_STX_PARSER_ERROR_BLOCK_NOT_CLOSED; diff --git a/ase/test/stx/test.st b/ase/test/stx/test.st index b9dc596e..927c3e12 100644 --- a/ase/test/stx/test.st +++ b/ase/test/stx/test.st @@ -11,10 +11,4 @@ perform: method with: x with: y with: z with: a with: b with: c (jjj xxx: 10 xy) zzz: (10 fuck: 20 you: 40) yyy: kkk. -" - $a. - $b. - ^true. - a := b. - ' this is bad -" + [ 10 plus: 20]