fixed a lexer bug of eating up one more character when reading a single-letter identifier C, S, M followed by a non-identifier letter in get_ident().

changed various test programs according to syntax changes
This commit is contained in:
hyunghwan.chung
2017-04-24 09:20:27 +00:00
parent 5bf8d20a93
commit 8a0d476d18
16 changed files with 98 additions and 80 deletions

View File

@ -945,12 +945,13 @@ static int get_ident (moo_t* moo, moo_ooci_t char_read_ahead)
ADD_TOKEN_CHAR(moo, char_read_ahead);
}
do
/* while() instead of do..while() because when char_read_ahead is not EOF
* c may not be a identifier character */
while (is_identchar(c))
{
ADD_TOKEN_CHAR (moo, c);
GET_CHAR_TO (moo, c);
}
while (is_identchar(c));
if (c == '(' && is_token_word(moo, VOCA_ERROR))
{
@ -3322,10 +3323,27 @@ static int compile_class_level_imports (moo_t* moo)
/* it falls back to the name space of the class */
ns_oop = moo->c->cls.ns_oop;
}
else break;
else if (TOKEN_TYPE(moo) == MOO_IOTOK_COMMA || TOKEN_TYPE(moo) == MOO_IOTOK_EOF || TOKEN_TYPE(moo) == MOO_IOTOK_PERIOD)
{
/* no variable name is present */
set_syntax_error (moo, MOO_SYNERR_VARNAMEDUPL, TOKEN_LOC(moo), TOKEN_NAME(moo));
return -1;
}
else
{
break;
}
if (import_pool_dictionary(moo, ns_oop, &last, TOKEN_NAME(moo), TOKEN_LOC(moo)) <= -1) return -1;
GET_TOKEN (moo);
if (TOKEN_TYPE(moo) == MOO_IOTOK_IDENT_DOTTED || TOKEN_TYPE(moo) == MOO_IOTOK_IDENT)
{
set_syntax_error (moo, MOO_SYNERR_COMMA, TOKEN_LOC(moo), TOKEN_NAME(moo));
return -1;
}
else if (TOKEN_TYPE(moo) != MOO_IOTOK_COMMA) break; /* hopefully . */
GET_TOKEN (moo);
}
while (1);