summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-19 15:26:53 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-19 15:26:53 +0100
commit72dcd2da03b9c49d53429f781e10f81110a07a8c (patch)
treec86874fd5e10023ce155893b362e5ab67b417a6c
parent8834f8e02d37953b3a84d6946fc86b494dd3ea69 (diff)
eolian: add a functional "import" statement
Diffstat (limited to '')
-rw-r--r--src/bin/eolian/main.c2
-rw-r--r--src/lib/eolian/database_fill.c9
-rw-r--r--src/lib/eolian/eo_lexer.c2
-rw-r--r--src/lib/eolian/eo_parser.c33
-rw-r--r--src/lib/eolian/eolian_database.c7
-rw-r--r--src/lib/eolian/eolian_database.h4
6 files changed, 52 insertions, 5 deletions
diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index 091a383aa8..e45d2a7ee1 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -391,8 +391,6 @@ int main(int argc, char **argv)
391 goto end; 391 goto end;
392 } 392 }
393 393
394 eolian_all_eot_files_parse();
395
396 if (!eolian_eo_file_parse(eo_filename)) 394 if (!eolian_eo_file_parse(eo_filename))
397 { 395 {
398 ERR("Error during parsing file %s\n", eo_filename); 396 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 f019f99669..00dd224980 100644
--- a/src/lib/eolian/database_fill.c
+++ b/src/lib/eolian/database_fill.c
@@ -213,8 +213,12 @@ Eina_Bool
213eo_parser_database_fill(const char *filename, Eina_Bool eot) 213eo_parser_database_fill(const char *filename, Eina_Bool eot)
214{ 214{
215 Eolian_Class *cl; 215 Eolian_Class *cl;
216 Eo_Lexer *ls;
216 217
217 Eo_Lexer *ls = eo_lexer_new(filename); 218 if (eot && eina_hash_find(_parsedeots, filename))
219 return EINA_TRUE;
220
221 ls = eo_lexer_new(filename);
218 if (!ls) 222 if (!ls)
219 { 223 {
220 fprintf(stderr, "eolian: unable to create lexer for file '%s'\n", filename); 224 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)
249 } 253 }
250 254
251done: 255done:
256 if (eot)
257 eina_hash_set(_parsedeots, filename, (void *)EINA_TRUE);
258
252 eo_lexer_free(ls); 259 eo_lexer_free(ls);
253 return EINA_TRUE; 260 return EINA_TRUE;
254 261
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 32787f121a..c84df4b362 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)
659 ls->source = eina_stringshare_add(source); 659 ls->source = eina_stringshare_add(source);
660 ls->filename = get_filename(ls); 660 ls->filename = get_filename(ls);
661 ls->line_number = 1; 661 ls->line_number = 1;
662 ls->icolumn = ls->column = 0; 662 ls->icolumn = ls->column = -1;
663 next_char(ls); 663 next_char(ls);
664 if (ls->current != 0xEF) 664 if (ls->current != 0xEF)
665 return; 665 return;
diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c
index 24089aa0b9..30b1ced3b7 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)
1791 goto found_class; 1791 goto found_class;
1792 case KW_import: 1792 case KW_import:
1793 { 1793 {
1794 Eina_Strbuf *buf = push_strbuf(ls);
1795 const char *found = NULL;
1796 char errbuf[PATH_MAX];
1797 eo_lexer_get(ls);
1798 check(ls, TOK_VALUE);
1799 eina_strbuf_append(buf, ls->t.value.s);
1800 eina_strbuf_append(buf, ".eot");
1801 if (eina_hash_find(_parsingeots, ls->t.value.s))
1802 {
1803 pop_strbuf(ls);
1804 snprintf(errbuf, sizeof(errbuf),
1805 "cyclic import '%s'", ls->t.value.s);
1806 eo_lexer_syntax_error(ls, errbuf);
1807 }
1808 if (!(found = eina_hash_find(_tfilenames, eina_strbuf_string_get(buf))))
1809 {
1810 pop_strbuf(ls);
1811 snprintf(errbuf, sizeof(errbuf),
1812 "unknown import '%s'", ls->t.value.s);
1813 eo_lexer_syntax_error(ls, errbuf);
1814 }
1815 pop_strbuf(ls);
1816 eina_hash_set(_parsingeots, ls->t.value.s, (void *)EINA_TRUE);
1817 if (!eo_parser_database_fill(found, EINA_TRUE))
1818 {
1819 pop_strbuf(ls);
1820 snprintf(errbuf, sizeof(errbuf),
1821 "error while parsing import '%s'", ls->t.value.s);
1822 eo_lexer_syntax_error(ls, errbuf);
1823 }
1824 eina_hash_set(_parsingeots, ls->t.value.s, (void *)EINA_FALSE);
1825 pop_strbuf(ls);
1794 eo_lexer_get(ls); 1826 eo_lexer_get(ls);
1795 check_next(ls, TOK_VALUE);
1796 check_next(ls, ';'); 1827 check_next(ls, ';');
1797 break; 1828 break;
1798 } 1829 }
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index 615c7741ad..9e71ec0140 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -24,6 +24,9 @@ Eina_Hash *_tfilenames = NULL;
24Eina_Hash *_depclasses = NULL; 24Eina_Hash *_depclasses = NULL;
25Eina_Hash *_decls = NULL; 25Eina_Hash *_decls = NULL;
26 26
27Eina_Hash *_parsedeots = NULL;
28Eina_Hash *_parsingeots = NULL;
29
27static int _database_init_count = 0; 30static int _database_init_count = 0;
28 31
29static void 32static void
@@ -66,6 +69,8 @@ database_init()
66 _tfilenames = eina_hash_string_small_new(free); 69 _tfilenames = eina_hash_string_small_new(free);
67 _depclasses = eina_hash_stringshared_new(EINA_FREE_CB(_deplist_free)); 70 _depclasses = eina_hash_stringshared_new(EINA_FREE_CB(_deplist_free));
68 _decls = eina_hash_stringshared_new(free); 71 _decls = eina_hash_stringshared_new(free);
72 _parsedeots = eina_hash_string_small_new(NULL);
73 _parsingeots = eina_hash_string_small_new(NULL);
69 return ++_database_init_count; 74 return ++_database_init_count;
70} 75}
71 76
@@ -97,6 +102,8 @@ database_shutdown()
97 eina_hash_free(_tfilenames); _tfilenames = NULL; 102 eina_hash_free(_tfilenames); _tfilenames = NULL;
98 eina_hash_free(_depclasses); _depclasses = NULL; 103 eina_hash_free(_depclasses); _depclasses = NULL;
99 eina_hash_free(_decls ); _decls = NULL; 104 eina_hash_free(_decls ); _decls = NULL;
105 eina_hash_free(_parsedeots); _parsedeots = NULL;
106 eina_hash_free(_parsingeots); _parsingeots = NULL;
100 eina_shutdown(); 107 eina_shutdown();
101 } 108 }
102 return _database_init_count; 109 return _database_init_count;
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 5ea8674a06..5910152cb4 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -52,6 +52,10 @@ extern Eina_Hash *_depclasses;
52/* a hash holding all declarations, for redef checking etc */ 52/* a hash holding all declarations, for redef checking etc */
53extern Eina_Hash *_decls; 53extern Eina_Hash *_decls;
54 54
55/* holds parsed/currently parsing eot files to keep track */
56extern Eina_Hash *_parsedeots;
57extern Eina_Hash *_parsingeots;
58
55typedef struct _Eolian_Object 59typedef struct _Eolian_Object
56{ 60{
57 const char *file; 61 const char *file;