forked from enlightenment/efl
eolian: check redefinitions in the parser instead (provides line info)
This commit is contained in:
parent
9262a82ed3
commit
6f805a9998
|
@ -459,18 +459,12 @@ nodeloop:
|
||||||
break;
|
break;
|
||||||
case NODE_TYPEDEF:
|
case NODE_TYPEDEF:
|
||||||
if (!database_type_add(nd->def_typedef))
|
if (!database_type_add(nd->def_typedef))
|
||||||
{
|
goto error;
|
||||||
ERR("Redefinition of typedef %s\n", nd->def_typedef->alias);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
nd->def_typedef = NULL;
|
nd->def_typedef = NULL;
|
||||||
break;
|
break;
|
||||||
case NODE_STRUCT:
|
case NODE_STRUCT:
|
||||||
if (!database_struct_add(nd->def_struct))
|
if (!database_struct_add(nd->def_struct))
|
||||||
{
|
goto error;
|
||||||
ERR("Redefinition of struct %s\n", nd->def_struct->name);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
nd->def_struct = NULL;
|
nd->def_struct = NULL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -37,7 +37,6 @@ Eina_Bool
|
||||||
database_type_add(Eolian_Typedef *def)
|
database_type_add(Eolian_Typedef *def)
|
||||||
{
|
{
|
||||||
if (!_types) return EINA_FALSE;
|
if (!_types) return EINA_FALSE;
|
||||||
if (eina_hash_find(_types, def->alias)) return EINA_FALSE;
|
|
||||||
eina_hash_set(_types, def->alias, def);
|
eina_hash_set(_types, def->alias, def);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +44,6 @@ database_type_add(Eolian_Typedef *def)
|
||||||
Eina_Bool database_struct_add(Eolian_Type *tp)
|
Eina_Bool database_struct_add(Eolian_Type *tp)
|
||||||
{
|
{
|
||||||
if (!_structs) return EINA_FALSE;
|
if (!_structs) return EINA_FALSE;
|
||||||
if (eina_hash_find(_structs, tp->name)) return EINA_FALSE;
|
|
||||||
eina_hash_set(_structs, tp->name, tp);
|
eina_hash_set(_structs, tp->name, tp);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,6 +329,9 @@ parse_type_struct(Eo_Lexer *ls, Eina_Bool allow_struct, Eina_Bool allow_anon)
|
||||||
check(ls, TOK_VALUE);
|
check(ls, TOK_VALUE);
|
||||||
if (eo_lexer_get_c_type(ls->t.kw))
|
if (eo_lexer_get_c_type(ls->t.kw))
|
||||||
eo_lexer_syntax_error(ls, "invalid struct name");
|
eo_lexer_syntax_error(ls, "invalid struct name");
|
||||||
|
/* todo: see typedef */
|
||||||
|
if (eina_hash_find(_structs, ls->t.value))
|
||||||
|
eo_lexer_syntax_error(ls, "struct redefinition");
|
||||||
sname = eina_stringshare_ref(ls->t.value);
|
sname = eina_stringshare_ref(ls->t.value);
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
if (ls->t.token == '{')
|
if (ls->t.token == '{')
|
||||||
|
@ -407,6 +410,9 @@ parse_typedef(Eo_Lexer *ls)
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
}
|
}
|
||||||
check(ls, TOK_VALUE);
|
check(ls, TOK_VALUE);
|
||||||
|
/* todo: store info about the previous definition and mention it here */
|
||||||
|
if (eina_hash_find(_types, ls->t.value))
|
||||||
|
eo_lexer_syntax_error(ls, "typedef redefinition");
|
||||||
ls->tmp.typedef_def->alias = eina_stringshare_ref(ls->t.value);
|
ls->tmp.typedef_def->alias = eina_stringshare_ref(ls->t.value);
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
(void)!!test_next(ls, ':');
|
(void)!!test_next(ls, ':');
|
||||||
|
@ -1071,6 +1077,9 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
|
||||||
check(ls, TOK_VALUE);
|
check(ls, TOK_VALUE);
|
||||||
if (eo_lexer_get_c_type(ls->t.kw))
|
if (eo_lexer_get_c_type(ls->t.kw))
|
||||||
eo_lexer_syntax_error(ls, "invalid struct name");
|
eo_lexer_syntax_error(ls, "invalid struct name");
|
||||||
|
/* todo: see typedef */
|
||||||
|
if (eina_hash_find(_structs, ls->t.value))
|
||||||
|
eo_lexer_syntax_error(ls, "struct redefinition");
|
||||||
name = eina_stringshare_ref(ls->t.value);
|
name = eina_stringshare_ref(ls->t.value);
|
||||||
eo_lexer_get(ls);
|
eo_lexer_get(ls);
|
||||||
parse_struct(ls, name, is_extern);
|
parse_struct(ls, name, is_extern);
|
||||||
|
|
Loading…
Reference in New Issue