q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=6f805a999845ab4b198dd10fbe9decfa0e128ddd

commit 6f805a999845ab4b198dd10fbe9decfa0e128ddd
Author: Daniel Kolesa <[email protected]>
Date:   Mon Jul 21 11:34:14 2014 +0100

    eolian: check redefinitions in the parser instead (provides line info)
---
 src/lib/eolian/database_fill.c | 10 ++--------
 src/lib/eolian/database_type.c |  2 --
 src/lib/eolian/eo_parser.c     |  9 +++++++++
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/lib/eolian/database_fill.c b/src/lib/eolian/database_fill.c
index 6da91b8..f4c4493 100644
--- a/src/lib/eolian/database_fill.c
+++ b/src/lib/eolian/database_fill.c
@@ -459,18 +459,12 @@ nodeloop:
              break;
            case NODE_TYPEDEF:
              if (!database_type_add(nd->def_typedef))
-               {
-                  ERR("Redefinition of typedef %s\n", nd->def_typedef->alias);
-                  goto error;
-               }
+               goto error;
              nd->def_typedef = NULL;
              break;
            case NODE_STRUCT:
              if (!database_struct_add(nd->def_struct))
-               {
-                  ERR("Redefinition of struct %s\n", nd->def_struct->name);
-                  goto error;
-               }
+               goto error;
              nd->def_struct = NULL;
              break;
            default:
diff --git a/src/lib/eolian/database_type.c b/src/lib/eolian/database_type.c
index 187185c..83e44bb 100644
--- a/src/lib/eolian/database_type.c
+++ b/src/lib/eolian/database_type.c
@@ -37,7 +37,6 @@ Eina_Bool
 database_type_add(Eolian_Typedef *def)
 {
    if (!_types) return EINA_FALSE;
-   if (eina_hash_find(_types, def->alias)) return EINA_FALSE;
    eina_hash_set(_types, def->alias, def);
    return EINA_TRUE;
 }
@@ -45,7 +44,6 @@ database_type_add(Eolian_Typedef *def)
 Eina_Bool database_struct_add(Eolian_Type *tp)
 {
    if (!_structs) return EINA_FALSE;
-   if (eina_hash_find(_structs, tp->name)) return EINA_FALSE;
    eina_hash_set(_structs, tp->name, tp);
    return EINA_TRUE;
 }
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index d5bdc0c..8c4a4f3 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -329,6 +329,9 @@ parse_type_struct(Eo_Lexer *ls, Eina_Bool allow_struct, 
Eina_Bool allow_anon)
              check(ls, TOK_VALUE);
              if (eo_lexer_get_c_type(ls->t.kw))
                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);
              eo_lexer_get(ls);
              if (ls->t.token == '{')
@@ -407,6 +410,9 @@ parse_typedef(Eo_Lexer *ls)
         eo_lexer_get(ls);
      }
    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);
    eo_lexer_get(ls);
    (void)!!test_next(ls, ':');
@@ -1071,6 +1077,9 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
            check(ls, TOK_VALUE);
            if (eo_lexer_get_c_type(ls->t.kw))
              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);
            eo_lexer_get(ls);
            parse_struct(ls, name, is_extern);

-- 


Reply via email to