starting to write support 'const' defintion in a class

This commit is contained in:
hyunghwan.chung
2019-09-04 15:06:24 +00:00
parent 1bd41fc6c0
commit 00969032ff
3 changed files with 42 additions and 7 deletions

View File

@ -118,6 +118,7 @@ static struct voca_t
{ 5, { 'c','l','a','s','s' } },
{ 6, { '#','c','l','a','s','s' } },
{ 10, { '#','c','l','a','s','s','i','n','s','t' } },
{ 5, { 'c','o','n','s','t' } },
{ 8, { 'c','o','n','t','i','n','u','e' } },
{ 2, { 'd','o' } },
{ 5, { '#','d','u','a','l' } },
@ -187,6 +188,7 @@ enum voca_id_t
VOCA_CLASS,
VOCA_CLASS_S,
VOCA_CLASSINST_S,
VOCA_CONST,
VOCA_CONTINUE,
VOCA_DO,
VOCA_DUAL_S,
@ -430,6 +432,7 @@ static int is_restricted_word (const moo_oocs_t* ucs)
static int rw[] =
{
VOCA_CLASS,
VOCA_CONST,
VOCA_EXTEND,
VOCA_FROM,
VOCA_IMPORT,
@ -4014,6 +4017,12 @@ static int compile_class_level_imports (moo_t* moo)
return 0;
}
static int compile_class_level_consts (moo_t* moo)
{
/* TODO: */
return 0;
}
static int compile_unary_method_name (moo_t* moo, moo_method_data_t* mth)
{
MOO_ASSERT (moo, mth->name.len == 0);
@ -9068,6 +9077,9 @@ static int __compile_class_definition (moo_t* moo, int class_type)
}
while (1);
}
/* TODO: load constants here? */
}
else
{
@ -9104,6 +9116,12 @@ static int __compile_class_definition (moo_t* moo, int class_type)
GET_TOKEN (moo);
if (compile_class_level_imports(moo) <= -1) return -1;
}
else if (is_token_word(moo, VOCA_CONST))
{
/* constant declaration */
GET_TOKEN (moo);
if (compile_class_level_consts(moo) <= -1) return -1;
}
else break;
}
while (1);