forked from enlightenment/efl
eolian: add a functional "import" statement
This commit is contained in:
parent
8834f8e02d
commit
72dcd2da03
|
@ -391,8 +391,6 @@ int main(int argc, char **argv)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
eolian_all_eot_files_parse();
|
|
||||||
|
|
||||||
if (!eolian_eo_file_parse(eo_filename))
|
if (!eolian_eo_file_parse(eo_filename))
|
||||||
{
|
{
|
||||||
ERR("Error during parsing file %s\n", eo_filename);
|
ERR("Error during parsing file %s\n", eo_filename);
|
||||||
|
|
|
@ -213,8 +213,12 @@ Eina_Bool
|
||||||
eo_parser_database_fill(const char *filename, Eina_Bool eot)
|
eo_parser_database_fill(const char *filename, Eina_Bool eot)
|
||||||
{
|
{
|
||||||
Eolian_Class *cl;
|
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)
|
if (!ls)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "eolian: unable to create lexer for file '%s'\n", filename);
|
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:
|
done:
|
||||||
|
if (eot)
|
||||||
|
eina_hash_set(_parsedeots, filename, (void *)EINA_TRUE);
|
||||||
|
|
||||||
eo_lexer_free(ls);
|
eo_lexer_free(ls);
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
|
|
||||||
|
|
|
@ -659,7 +659,7 @@ eo_lexer_set_input(Eo_Lexer *ls, const char *source)
|
||||||
ls->source = eina_stringshare_add(source);
|
ls->source = eina_stringshare_add(source);
|
||||||
ls->filename = get_filename(ls);
|
ls->filename = get_filename(ls);
|
||||||
ls->line_number = 1;
|
ls->line_number = 1;
|
||||||
ls->icolumn = ls->column = 0;
|
ls->icolumn = ls->column = -1;
|
||||||
next_char(ls);
|
next_char(ls);
|
||||||
if (ls->current != 0xEF)
|
if (ls->current != 0xEF)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1791,8 +1791,39 @@ parse_unit(Eo_Lexer *ls, Eina_Bool eot)
|
||||||
goto found_class;
|
goto found_class;
|
||||||
case KW_import:
|
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);
|
eo_lexer_get(ls);
|
||||||
check_next(ls, TOK_VALUE);
|
|
||||||
check_next(ls, ';');
|
check_next(ls, ';');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ Eina_Hash *_tfilenames = NULL;
|
||||||
Eina_Hash *_depclasses = NULL;
|
Eina_Hash *_depclasses = NULL;
|
||||||
Eina_Hash *_decls = NULL;
|
Eina_Hash *_decls = NULL;
|
||||||
|
|
||||||
|
Eina_Hash *_parsedeots = NULL;
|
||||||
|
Eina_Hash *_parsingeots = NULL;
|
||||||
|
|
||||||
static int _database_init_count = 0;
|
static int _database_init_count = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -66,6 +69,8 @@ database_init()
|
||||||
_tfilenames = eina_hash_string_small_new(free);
|
_tfilenames = eina_hash_string_small_new(free);
|
||||||
_depclasses = eina_hash_stringshared_new(EINA_FREE_CB(_deplist_free));
|
_depclasses = eina_hash_stringshared_new(EINA_FREE_CB(_deplist_free));
|
||||||
_decls = eina_hash_stringshared_new(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;
|
return ++_database_init_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +102,8 @@ database_shutdown()
|
||||||
eina_hash_free(_tfilenames); _tfilenames = NULL;
|
eina_hash_free(_tfilenames); _tfilenames = NULL;
|
||||||
eina_hash_free(_depclasses); _depclasses = NULL;
|
eina_hash_free(_depclasses); _depclasses = NULL;
|
||||||
eina_hash_free(_decls ); _decls = NULL;
|
eina_hash_free(_decls ); _decls = NULL;
|
||||||
|
eina_hash_free(_parsedeots); _parsedeots = NULL;
|
||||||
|
eina_hash_free(_parsingeots); _parsingeots = NULL;
|
||||||
eina_shutdown();
|
eina_shutdown();
|
||||||
}
|
}
|
||||||
return _database_init_count;
|
return _database_init_count;
|
||||||
|
|
|
@ -52,6 +52,10 @@ extern Eina_Hash *_depclasses;
|
||||||
/* a hash holding all declarations, for redef checking etc */
|
/* a hash holding all declarations, for redef checking etc */
|
||||||
extern Eina_Hash *_decls;
|
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
|
typedef struct _Eolian_Object
|
||||||
{
|
{
|
||||||
const char *file;
|
const char *file;
|
||||||
|
|
Loading…
Reference in New Issue