removed the association literal notation
This commit is contained in:
@ -219,7 +219,7 @@ static MOO_INLINE int is_binselchar (moo_ooci_t c)
|
||||
{
|
||||
/*
|
||||
* binary-selector-character :=
|
||||
* '%' | '&' | '*' | '+' | '-' |
|
||||
* '%' | '&' | '*' | '+' | '-' |
|
||||
* '/' | '<' | '>' | '=' | '?' |
|
||||
* '@' | '\' | '~' | '|'
|
||||
*/
|
||||
@ -965,6 +965,7 @@ static int get_ident (moo_t* moo, moo_ooci_t char_read_ahead)
|
||||
}
|
||||
else if (c == ':')
|
||||
{
|
||||
#if 0
|
||||
read_more_kwsym:
|
||||
ADD_TOKEN_CHAR (moo, c);
|
||||
SET_TOKEN_TYPE (moo, MOO_IOTOK_KEYWORD);
|
||||
@ -996,6 +997,24 @@ static int get_ident (moo_t* moo, moo_ooci_t char_read_ahead)
|
||||
{
|
||||
unget_char (moo, &moo->c->lxc);
|
||||
}
|
||||
#else
|
||||
moo_iolxc_t lc = moo->c->lxc;
|
||||
|
||||
GET_CHAR_TO (moo, c);
|
||||
|
||||
if (c == '=' || c == '{')
|
||||
{
|
||||
/* := or :{ appeared after an identifier */
|
||||
unget_char (moo, &moo->c->lxc);
|
||||
unget_char (moo, &lc);
|
||||
}
|
||||
else
|
||||
{
|
||||
ADD_TOKEN_CHAR (moo, lc.c);
|
||||
SET_TOKEN_TYPE (moo, MOO_IOTOK_KEYWORD);
|
||||
unget_char (moo, &moo->c->lxc);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1538,11 +1557,6 @@ retry:
|
||||
SET_TOKEN_TYPE (moo, MOO_IOTOK_DICBRACE);
|
||||
ADD_TOKEN_CHAR (moo, c);
|
||||
}
|
||||
else if (c == '(')
|
||||
{
|
||||
SET_TOKEN_TYPE (moo, MOO_IOTOK_ASSPAREN);
|
||||
ADD_TOKEN_CHAR (moo, c);
|
||||
}
|
||||
else
|
||||
{
|
||||
unget_char (moo, &moo->c->lxc);
|
||||
@ -3458,6 +3472,7 @@ static int get_variable_info (moo_t* moo, const moo_oocs_t* name, const moo_iolo
|
||||
*
|
||||
* self.XXX - instance variable
|
||||
* A.B.C - namespace or pool dictionary related reference.
|
||||
* self.B.C - B.C under the current class where B is not an instance variable
|
||||
*/
|
||||
|
||||
moo_oocs_t last;
|
||||
@ -4193,55 +4208,6 @@ static int compile_array_expression (moo_t* moo)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int compile_association_expression (moo_t* moo)
|
||||
{
|
||||
MOO_ASSERT (moo, TOKEN_TYPE(moo) == MOO_IOTOK_ASSPAREN);
|
||||
|
||||
GET_TOKEN (moo); /* read a token after #{ */
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_RPAREN)
|
||||
{
|
||||
/* key is required */
|
||||
set_syntax_error (moo, MOO_SYNERR_NOASSKEY, TOKEN_LOC(moo), MOO_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (emit_byte_instruction (moo, BCODE_MAKE_ASSOCIATION) <= -1) return -1;
|
||||
|
||||
if (compile_method_expression (moo, 0) <= -1) return -1;
|
||||
if (emit_byte_instruction (moo, BCODE_POP_INTO_ASSOCIATION_KEY) <= -1) return -1;
|
||||
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_RPAREN)
|
||||
{
|
||||
/* no comma, no value is specified. */
|
||||
goto done;
|
||||
}
|
||||
else if (TOKEN_TYPE(moo) != MOO_IOTOK_COMMA)
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_COMMA, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
return -1;
|
||||
}
|
||||
|
||||
GET_TOKEN (moo); /* read a token after the comma */
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_RPAREN)
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_NOASSVALUE, TOKEN_LOC(moo), MOO_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (compile_method_expression (moo, 0) <= -1) return -1;
|
||||
if (emit_byte_instruction (moo, BCODE_POP_INTO_ASSOCIATION_VALUE) <= -1) return -1;
|
||||
|
||||
if (TOKEN_TYPE(moo) != MOO_IOTOK_RPAREN)
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_RPAREN, TOKEN_LOC(moo), TOKEN_NAME(moo));
|
||||
return -1;
|
||||
}
|
||||
|
||||
done:
|
||||
GET_TOKEN (moo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int compile_dictionary_expression (moo_t* moo)
|
||||
{
|
||||
moo_oow_t mdip;
|
||||
@ -4260,17 +4226,10 @@ static int compile_dictionary_expression (moo_t* moo)
|
||||
count = 0;
|
||||
do
|
||||
{
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_ASSPAREN)
|
||||
{
|
||||
if (compile_association_expression(moo) <= -1 ||
|
||||
emit_byte_instruction (moo, BCODE_POP_INTO_DICTIONARY) <= -1) return -1;
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
set_syntax_error (moo, MOO_SYNERR_NOASSOC, TOKEN_LOC(moo), MOO_NULL);
|
||||
return -1;
|
||||
}
|
||||
if (compile_method_expression (moo, 0) <= -1 ||
|
||||
emit_byte_instruction (moo, BCODE_POP_INTO_DICTIONARY) <= -1) return -1;
|
||||
|
||||
count++;
|
||||
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_RBRACE) break;
|
||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_COMMA)
|
||||
@ -4498,10 +4457,6 @@ static int compile_expression_primary (moo_t* moo, const moo_oocs_t* ident, cons
|
||||
if (compile_array_expression(moo) <= -1) return -1;
|
||||
break;
|
||||
|
||||
case MOO_IOTOK_ASSPAREN: /* :( */
|
||||
if (compile_association_expression(moo) <= -1) return -1;
|
||||
break;
|
||||
|
||||
case MOO_IOTOK_DICBRACE: /* :{ */
|
||||
if (compile_dictionary_expression(moo) <= -1) return -1;
|
||||
break;
|
||||
@ -4689,7 +4644,7 @@ static int compile_keyword_message (moo_t* moo, int to_super)
|
||||
|
||||
nargs++;
|
||||
}
|
||||
while (TOKEN_TYPE(moo) == MOO_IOTOK_KEYWORD);
|
||||
while (TOKEN_TYPE(moo) == MOO_IOTOK_KEYWORD) /* loop */;
|
||||
|
||||
kwsel.ptr = &moo->c->mth.kwsels.ptr[saved_kwsel_len];
|
||||
kwsel.len = moo->c->mth.kwsels.len - saved_kwsel_len;
|
||||
|
@ -505,18 +505,6 @@ int moo_decode (moo_t* moo, moo_oop_method_t mth, const moo_oocs_t* classfqn)
|
||||
LOG_INST_0 (moo, "pop_into_dictionary");
|
||||
break;
|
||||
|
||||
case BCODE_MAKE_ASSOCIATION:
|
||||
LOG_INST_0 (moo, "make_association");
|
||||
break;
|
||||
|
||||
case BCODE_POP_INTO_ASSOCIATION_KEY:
|
||||
LOG_INST_0 (moo, "pop_into_association_key");
|
||||
break;
|
||||
|
||||
case BCODE_POP_INTO_ASSOCIATION_VALUE:
|
||||
LOG_INST_0 (moo, "pop_into_association_value");
|
||||
break;
|
||||
|
||||
case BCODE_MAKE_ARRAY:
|
||||
FETCH_PARAM_CODE_TO (moo, b1);
|
||||
LOG_INST_1 (moo, "make_array %zu", b1);
|
||||
|
@ -133,9 +133,7 @@ static moo_ooch_t synerrstr_61[] = {'l','i','t','e','r','a','l',' ','e','x','p',
|
||||
static moo_ooch_t synerrstr_62[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','n','o','t',' ','w','i','t','h','i','n',' ','a',' ','l','o','o','p','\0'};
|
||||
static moo_ooch_t synerrstr_63[] = {'b','r','e','a','k',' ','o','r',' ','c','o','n','t','i','n','u','e',' ','w','i','t','h','i','n',' ','a',' ','b','l','o','c','k','\0'};
|
||||
static moo_ooch_t synerrstr_64[] = {'w','h','i','l','e',' ','e','x','p','e','c','t','e','d','\0'};
|
||||
static moo_ooch_t synerrstr_65[] = {'m','i','s','s','i','n','g',' ','a','s','s','o','c','i','a','t','i','o','n',' ','k','e','y','\0'};
|
||||
static moo_ooch_t synerrstr_66[] = {'m','i','s','s','i','n','g',' ','a','s','s','o','c','i','a','t','i','o','n',' ','v','a','l','u','e','\0'};
|
||||
static moo_ooch_t synerrstr_67[] = {'m','i','s','s','i','n','g',' ','a','s','s','o','c','i','a','t','i','o','n','\0'};
|
||||
|
||||
static moo_ooch_t* synerrstr[] =
|
||||
{
|
||||
synerrstr_0, synerrstr_1, synerrstr_2, synerrstr_3, synerrstr_4, synerrstr_5, synerrstr_6, synerrstr_7,
|
||||
@ -146,7 +144,7 @@ static moo_ooch_t* synerrstr[] =
|
||||
synerrstr_40, synerrstr_41, synerrstr_42, synerrstr_43, synerrstr_44, synerrstr_45, synerrstr_46, synerrstr_47,
|
||||
synerrstr_48, synerrstr_49, synerrstr_50, synerrstr_51, synerrstr_52, synerrstr_53, synerrstr_54, synerrstr_55,
|
||||
synerrstr_56, synerrstr_57, synerrstr_58, synerrstr_59, synerrstr_60, synerrstr_61, synerrstr_62, synerrstr_63,
|
||||
synerrstr_64, synerrstr_65, synerrstr_66, synerrstr_67
|
||||
synerrstr_64
|
||||
};
|
||||
#endif
|
||||
/* END: GENERATED WITH generr.moo */
|
||||
|
@ -3893,45 +3893,6 @@ int moo_execute (moo_t* moo)
|
||||
if (send_message (moo, moo->dicputassocsym, 0, 1) <= -1) goto oops;
|
||||
break;
|
||||
|
||||
case BCODE_MAKE_ASSOCIATION:
|
||||
{
|
||||
moo_oop_t t;
|
||||
|
||||
LOG_INST_0 (moo, "make_association");
|
||||
|
||||
t = moo_instantiate (moo, moo->_association, MOO_NULL, 0);
|
||||
if (!t) goto oops;
|
||||
|
||||
MOO_STACK_PUSH (moo, t); /* push the association created */
|
||||
break;
|
||||
}
|
||||
|
||||
case BCODE_POP_INTO_ASSOCIATION_KEY:
|
||||
{
|
||||
moo_oop_t t1, t2;
|
||||
|
||||
LOG_INST_0 (moo, "pop_into_association_key");
|
||||
|
||||
t1 = MOO_STACK_GETTOP(moo);
|
||||
MOO_STACK_POP (moo);
|
||||
t2 = MOO_STACK_GETTOP(moo);
|
||||
((moo_oop_association_t)t2)->key = t1;
|
||||
break;
|
||||
}
|
||||
|
||||
case BCODE_POP_INTO_ASSOCIATION_VALUE:
|
||||
{
|
||||
moo_oop_t t1, t2;
|
||||
|
||||
LOG_INST_0 (moo, "pop_into_association_value");
|
||||
|
||||
t1 = MOO_STACK_GETTOP(moo);
|
||||
MOO_STACK_POP (moo);
|
||||
t2 = MOO_STACK_GETTOP(moo);
|
||||
((moo_oop_association_t)t2)->value = t1;
|
||||
break;
|
||||
}
|
||||
|
||||
case BCODE_MAKE_ARRAY:
|
||||
{
|
||||
moo_oop_t t;
|
||||
|
@ -325,7 +325,6 @@ struct moo_iotok_t
|
||||
MOO_IOTOK_BABRACK, /* #[ - byte array literal */
|
||||
MOO_IOTOK_ABRACE, /* #{ - array expression */
|
||||
MOO_IOTOK_DICBRACE, /* :{ - dictionary expression */
|
||||
MOO_IOTOK_ASSPAREN, /* :( - association expression */
|
||||
MOO_IOTOK_PERIOD,
|
||||
MOO_IOTOK_COMMA,
|
||||
MOO_IOTOK_SEMICOLON,
|
||||
@ -863,14 +862,13 @@ enum moo_bcode_t
|
||||
BCODE_POP_INTO_OBJVAR_X = 0xEC, /* 236 ## */
|
||||
|
||||
/* UNUSED 237 */
|
||||
|
||||
BCODE_MAKE_DICTIONARY = 0xEE, /* 238 */
|
||||
BCODE_POP_INTO_DICTIONARY = 0xEF, /* 239 */
|
||||
/* UNUSED 238 */
|
||||
/* UNUSED 239 */
|
||||
|
||||
BCODE_SEND_MESSAGE_X = 0xF0, /* 240 ## */
|
||||
BCODE_MAKE_ASSOCIATION = 0xF1, /* 241 */
|
||||
BCODE_POP_INTO_ASSOCIATION_KEY = 0xF2, /* 242 */
|
||||
BCODE_POP_INTO_ASSOCIATION_VALUE = 0xF3, /* 243 */
|
||||
/* UNUSED 241 */
|
||||
BCODE_MAKE_DICTIONARY = 0xF2, /* 242 */
|
||||
BCODE_POP_INTO_DICTIONARY = 0xF3, /* 243 */
|
||||
BCODE_SEND_MESSAGE_TO_SUPER_X = 0xF4, /* 244 ## */
|
||||
|
||||
/* -------------------------------------- */
|
||||
|
@ -1237,10 +1237,7 @@ enum moo_synerrnum_t
|
||||
MOO_SYNERR_LITERAL, /* literal expected */
|
||||
MOO_SYNERR_NOTINLOOP, /* break or continue not within a loop */
|
||||
MOO_SYNERR_INBLOCK, /* break or continue within a block */
|
||||
MOO_SYNERR_WHILE, /* while expected */
|
||||
MOO_SYNERR_NOASSKEY, /* missing association key */
|
||||
MOO_SYNERR_NOASSVALUE, /* missing association value */
|
||||
MOO_SYNERR_NOASSOC /* missing association */
|
||||
MOO_SYNERR_WHILE /* while expected */
|
||||
};
|
||||
typedef enum moo_synerrnum_t moo_synerrnum_t;
|
||||
|
||||
|
Reference in New Issue
Block a user