q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=72dcd2da03b9c49d53429f781e10f81110a07a8c

commit 72dcd2da03b9c49d53429f781e10f81110a07a8c
Author: Daniel Kolesa <d.kol...@osg.samsung.com>
Date:   Tue May 19 15:26:53 2015 +0100

    eolian: add a functional "import" statement
---
 src/bin/eolian/main.c            |  2 --
 src/lib/eolian/database_fill.c   |  9 ++++++++-
 src/lib/eolian/eo_lexer.c        |  2 +-
 src/lib/eolian/eo_parser.c       | 33 ++++++++++++++++++++++++++++++++-
 src/lib/eolian/eolian_database.c |  7 +++++++
 src/lib/eolian/eolian_database.h |  4 ++++
 6 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index 091a383..e45d2a7 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -391,8 +391,6 @@ int main(int argc, char **argv)
         goto end;
      }
 
-   eolian_all_eot_files_parse();
-
    if (!eolian_eo_file_parse(eo_filename))
      {
         ERR("Error during parsing file %s\n", eo_filename);
diff --git a/src/lib/eolian/database_fill.c b/src/lib/eolian/database_fill.c
index f019f99..00dd224 100644
--- a/src/lib/eolian/database_fill.c
+++ b/src/lib/eolian/database_fill.c
@@ -213,8 +213,12 @@ Eina_Bool
 eo_parser_database_fill(const char *filename, Eina_Bool eot)
 {
    Eolian_Class *cl;
+   Eo_Lexer *ls;
 
-   Eo_Lexer *ls = eo_lexer_new(filename);
+   if (eot && eina_hash_find(_parsedeots, filename))
+     return EINA_TRUE;
+
+   ls = eo_lexer_new(filename);
    if (!ls)
      {
         fprintf(stderr, "eolian: unable to create lexer for file '%s'\n", 
filename);
@@ -249,6 +253,9 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
      }
 
 done:
+   if (eot)
+     eina_hash_set(_parsedeots, filename, (void *)EINA_TRUE);
+
    eo_lexer_free(ls);
    return EINA_TRUE;
 
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 32787f1..c84df4b 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -659,7 +659,7 @@ eo_lexer_set_input(Eo_Lexer *ls, const char *source)
    ls->source          = eina_stringshare_add(source);
    ls->filename        = get_filename(ls);
    ls->line_number     = 1;
-   ls->icolumn         = ls->column = 0;
+   ls->icolumn         = ls->column = -1;
    next_char(ls);
    if (ls->current != 0xEF)
      return;
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 24089aa..30b1ced 100644
--- a/src/lib/eolian/eo_parser.c
+++ b/src/lib/eolian/eo_parser.c
@@ -1791,8 +1791,39 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
         goto found_class;
       case KW_import:
         {
+           Eina_Strbuf *buf = push_strbuf(ls);
+           const char *found = NULL;
+           char errbuf[PATH_MAX];
+           eo_lexer_get(ls);
+           check(ls, TOK_VALUE);
+           eina_strbuf_append(buf, ls->t.value.s);
+           eina_strbuf_append(buf, ".eot");
+           if (eina_hash_find(_parsingeots, ls->t.value.s))
+             {
+                pop_strbuf(ls);
+                snprintf(errbuf, sizeof(errbuf),
+                         "cyclic import '%s'", ls->t.value.s);
+                eo_lexer_syntax_error(ls, errbuf);
+             }
+           if (!(found = eina_hash_find(_tfilenames, 
eina_strbuf_string_get(buf))))
+             {
+                pop_strbuf(ls);
+                snprintf(errbuf, sizeof(errbuf),
+                         "unknown import '%s'", ls->t.value.s);
+                eo_lexer_syntax_error(ls, errbuf);
+             }
+           pop_strbuf(ls);
+           eina_hash_set(_parsingeots, ls->t.value.s, (void *)EINA_TRUE);
+           if (!eo_parser_database_fill(found, EINA_TRUE))
+             {
+                pop_strbuf(ls);
+                snprintf(errbuf, sizeof(errbuf),
+                         "error while parsing import '%s'", ls->t.value.s);
+                eo_lexer_syntax_error(ls, errbuf);
+             }
+           eina_hash_set(_parsingeots, ls->t.value.s, (void *)EINA_FALSE);
+           pop_strbuf(ls);
            eo_lexer_get(ls);
-           check_next(ls, TOK_VALUE);
            check_next(ls, ';');
            break;
         }
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 615c774..9e71ec0 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -24,6 +24,9 @@ Eina_Hash *_tfilenames = NULL;
 Eina_Hash *_depclasses = NULL;
 Eina_Hash *_decls      = NULL;
 
+Eina_Hash *_parsedeots = NULL;
+Eina_Hash *_parsingeots = NULL;
+
 static int _database_init_count = 0;
 
 static void
@@ -66,6 +69,8 @@ database_init()
    _tfilenames = eina_hash_string_small_new(free);
    _depclasses = eina_hash_stringshared_new(EINA_FREE_CB(_deplist_free));
    _decls      = eina_hash_stringshared_new(free);
+   _parsedeots = eina_hash_string_small_new(NULL);
+   _parsingeots = eina_hash_string_small_new(NULL);
    return ++_database_init_count;
 }
 
@@ -97,6 +102,8 @@ database_shutdown()
         eina_hash_free(_tfilenames); _tfilenames = NULL;
         eina_hash_free(_depclasses); _depclasses = NULL;
         eina_hash_free(_decls     ); _decls      = NULL;
+        eina_hash_free(_parsedeots); _parsedeots = NULL;
+        eina_hash_free(_parsingeots); _parsingeots = NULL;
         eina_shutdown();
      }
    return _database_init_count;
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 5ea8674..5910152 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -52,6 +52,10 @@ extern Eina_Hash *_depclasses;
 /* a hash holding all declarations, for redef checking etc */
 extern Eina_Hash *_decls;
 
+/* holds parsed/currently parsing eot files to keep track */
+extern Eina_Hash *_parsedeots;
+extern Eina_Hash *_parsingeots;
+
 typedef struct _Eolian_Object
 {
    const char *file;

-- 


Reply via email to