2016-06-14 06:09:13 -07:00
|
|
|
#include <assert.h>
|
|
|
|
|
2014-09-23 12:48:16 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
#include "eo_parser.h"
|
|
|
|
|
2014-06-20 07:07:25 -07:00
|
|
|
#define CASE_LOCK(ls, var, msg) \
|
|
|
|
if (has_##var) \
|
2014-07-01 10:25:17 -07:00
|
|
|
eo_lexer_syntax_error(ls, "double " msg); \
|
2014-06-20 07:07:25 -07:00
|
|
|
has_##var = EINA_TRUE;
|
|
|
|
|
2015-02-18 07:41:50 -08:00
|
|
|
#define FILL_BASE(exp, ls, l, c) \
|
|
|
|
(exp).file = eina_stringshare_ref(ls->filename); \
|
|
|
|
(exp).line = l; \
|
|
|
|
(exp).column = c;
|
|
|
|
|
2015-06-03 07:35:13 -07:00
|
|
|
#define FILL_DOC(ls, def, docf) \
|
|
|
|
if (ls->t.token == TOK_DOC) \
|
|
|
|
{ \
|
|
|
|
def->docf = ls->t.value.doc; \
|
|
|
|
ls->t.value.doc = NULL; \
|
|
|
|
eo_lexer_get(ls); \
|
|
|
|
}
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
static void
|
|
|
|
error_expected(Eo_Lexer *ls, int token)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
char tbuf[256];
|
|
|
|
eo_lexer_token_to_str(token, tbuf);
|
|
|
|
snprintf(buf, sizeof(buf), "'%s' expected", tbuf);
|
|
|
|
eo_lexer_syntax_error(ls, buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
test_next(Eo_Lexer *ls, int token)
|
|
|
|
{
|
|
|
|
if (ls->t.token == token)
|
|
|
|
{
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
check(Eo_Lexer *ls, int token)
|
|
|
|
{
|
|
|
|
if (ls->t.token != token)
|
2014-07-01 10:25:17 -07:00
|
|
|
error_expected(ls, token);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
check_kw(Eo_Lexer *ls, int kw)
|
|
|
|
{
|
|
|
|
if (ls->t.kw != kw)
|
2014-07-01 10:25:17 -07:00
|
|
|
error_expected(ls, TOK_VALUE + kw);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
check_next(Eo_Lexer *ls, int token)
|
|
|
|
{
|
|
|
|
check(ls, token);
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
check_kw_next(Eo_Lexer *ls, int kw)
|
|
|
|
{
|
|
|
|
check_kw(ls, kw);
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-07-02 16:00:02 -07:00
|
|
|
check_match(Eo_Lexer *ls, int what, int who, int where, int col)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
|
|
|
if (!test_next(ls, what))
|
|
|
|
{
|
|
|
|
if (where == ls->line_number)
|
2014-07-01 10:25:17 -07:00
|
|
|
error_expected(ls, what);
|
2014-06-18 03:25:07 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
char tbuf[256];
|
|
|
|
char vbuf[256];
|
|
|
|
eo_lexer_token_to_str(what, tbuf);
|
|
|
|
eo_lexer_token_to_str(who , vbuf);
|
|
|
|
snprintf(buf, sizeof(buf),
|
2014-07-22 07:01:09 -07:00
|
|
|
"'%s' expected (to close '%s' at line %d, column %d)",
|
2014-07-02 16:00:02 -07:00
|
|
|
tbuf, vbuf, where, col);
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_syntax_error(ls, buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Strbuf *
|
|
|
|
push_strbuf(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
Eina_Strbuf *buf = eina_strbuf_new();
|
|
|
|
ls->tmp.str_bufs = eina_list_prepend(ls->tmp.str_bufs, buf);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pop_strbuf(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
Eina_Strbuf *buf = eina_list_data_get(ls->tmp.str_bufs);
|
|
|
|
eina_strbuf_free(buf);
|
|
|
|
ls->tmp.str_bufs = eina_list_remove_list(ls->tmp.str_bufs, ls->tmp.str_bufs);
|
|
|
|
}
|
|
|
|
|
2014-07-10 06:44:17 -07:00
|
|
|
static Eolian_Type *
|
2014-07-09 03:18:21 -07:00
|
|
|
push_type(Eo_Lexer *ls)
|
|
|
|
{
|
2014-07-10 06:44:17 -07:00
|
|
|
Eolian_Type *def = calloc(1, sizeof(Eolian_Type));
|
2014-07-09 03:18:21 -07:00
|
|
|
ls->tmp.type_defs = eina_list_prepend(ls->tmp.type_defs, def);
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
2016-03-01 07:37:57 -08:00
|
|
|
static Eolian_Typedecl *
|
|
|
|
push_typedecl(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
Eolian_Typedecl *def = calloc(1, sizeof(Eolian_Typedecl));
|
|
|
|
ls->tmp.type_decls = eina_list_prepend(ls->tmp.type_decls, def);
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
2014-07-09 03:18:21 -07:00
|
|
|
static void
|
|
|
|
pop_type(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
ls->tmp.type_defs = eina_list_remove_list(ls->tmp.type_defs, ls->tmp.type_defs);
|
|
|
|
}
|
|
|
|
|
2016-03-01 07:37:57 -08:00
|
|
|
static void
|
|
|
|
pop_typedecl(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
ls->tmp.type_decls = eina_list_remove_list(ls->tmp.type_decls, ls->tmp.type_decls);
|
|
|
|
}
|
|
|
|
|
2014-08-19 08:37:29 -07:00
|
|
|
static Eina_Stringshare *
|
|
|
|
push_str(Eo_Lexer *ls, const char *val)
|
|
|
|
{
|
|
|
|
Eina_Stringshare *shr = eina_stringshare_add(val);
|
|
|
|
ls->tmp.strs = eina_list_prepend(ls->tmp.strs, shr);
|
|
|
|
return shr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pop_str(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
ls->tmp.strs = eina_list_remove_list(ls->tmp.strs, ls->tmp.strs);
|
|
|
|
}
|
|
|
|
|
2014-08-01 05:59:46 -07:00
|
|
|
static Eina_Bool
|
2015-02-11 06:58:53 -08:00
|
|
|
compare_class_file(const char *fn1, const char *fn2)
|
2014-08-01 05:59:46 -07:00
|
|
|
{
|
2015-02-11 06:58:53 -08:00
|
|
|
return !strcmp(fn1, fn2);
|
2014-08-01 05:59:46 -07:00
|
|
|
}
|
|
|
|
|
2015-05-15 07:10:58 -07:00
|
|
|
static const char *declnames[] = {
|
|
|
|
"class", "type alias", "struct", "enum", "variable"
|
|
|
|
};
|
|
|
|
|
2014-07-22 07:01:09 -07:00
|
|
|
static void
|
2015-05-15 07:10:58 -07:00
|
|
|
redef_error(Eo_Lexer *ls, Eolian_Declaration *decl, Eolian_Declaration_Type newt)
|
2014-07-22 07:01:09 -07:00
|
|
|
{
|
2015-05-15 07:10:58 -07:00
|
|
|
Eolian_Object *obj = (Eolian_Object *)decl->data;
|
|
|
|
char buf[256], fbuf[256] = { '\0' };
|
|
|
|
if (ls->filename != obj->file)
|
|
|
|
snprintf(fbuf, sizeof(fbuf), "%s:%d:%d", obj->file, obj->line, obj->column);
|
|
|
|
else
|
|
|
|
snprintf(fbuf, sizeof(fbuf), "%d:%d", obj->line, obj->column);
|
|
|
|
|
|
|
|
if (newt != decl->type)
|
|
|
|
snprintf(buf, sizeof(buf), "%s '%s' redefined as %s (originally at %s)",
|
|
|
|
declnames[decl->type], decl->name, declnames[newt], fbuf);
|
|
|
|
else
|
|
|
|
snprintf(buf, sizeof(buf), "%s '%s' redefined (originally at %s)",
|
|
|
|
declnames[decl->type], decl->name, fbuf);
|
|
|
|
|
2014-07-22 07:01:09 -07:00
|
|
|
eo_lexer_syntax_error(ls, buf);
|
|
|
|
}
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
static Eina_Strbuf *
|
|
|
|
parse_name(Eo_Lexer *ls, Eina_Strbuf *buf)
|
|
|
|
{
|
|
|
|
check(ls, TOK_VALUE);
|
2016-06-30 06:04:03 -07:00
|
|
|
if (eo_lexer_is_type_keyword(ls->t.kw))
|
2014-07-21 07:11:19 -07:00
|
|
|
eo_lexer_syntax_error(ls, "invalid name");
|
2014-06-18 03:25:07 -07:00
|
|
|
eina_strbuf_reset(buf);
|
|
|
|
for (;;)
|
|
|
|
{
|
2014-07-17 09:16:31 -07:00
|
|
|
eina_strbuf_append(buf, ls->t.value.s);
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-06-20 02:45:55 -07:00
|
|
|
if (ls->t.token != '.') break;
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-06-20 02:45:55 -07:00
|
|
|
eina_strbuf_append(buf, ".");
|
2014-06-18 03:25:07 -07:00
|
|
|
check(ls, TOK_VALUE);
|
2016-06-30 06:04:03 -07:00
|
|
|
if (eo_lexer_is_type_keyword(ls->t.kw))
|
2014-07-21 07:11:19 -07:00
|
|
|
eo_lexer_syntax_error(ls, "invalid name");
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2014-09-11 02:50:48 -07:00
|
|
|
static void
|
2014-11-21 06:12:40 -08:00
|
|
|
_fill_name(const char *input, Eina_Stringshare **full_name,
|
|
|
|
Eina_Stringshare **name, Eina_List **namespaces)
|
2014-09-11 02:50:48 -07:00
|
|
|
{
|
2014-11-21 06:12:40 -08:00
|
|
|
char *fname = strdup(input);
|
|
|
|
char *sname = fname, *dot = fname;
|
|
|
|
*full_name = input;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
dot = strchr(dot, '.');
|
|
|
|
if (dot)
|
|
|
|
{
|
|
|
|
*dot = '\0';
|
|
|
|
*namespaces = eina_list_append(*namespaces,
|
|
|
|
eina_stringshare_add(sname));
|
|
|
|
++dot;
|
|
|
|
sname = dot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (dot);
|
|
|
|
*name = eina_stringshare_add(sname);
|
|
|
|
free(fname);
|
2014-09-11 02:50:48 -07:00
|
|
|
}
|
|
|
|
|
2014-07-17 09:16:31 -07:00
|
|
|
static Eolian_Expression *
|
|
|
|
push_expr(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
Eolian_Expression *def = calloc(1, sizeof(Eolian_Expression));
|
|
|
|
ls->tmp.expr_defs = eina_list_prepend(ls->tmp.expr_defs, def);
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pop_expr(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
ls->tmp.expr_defs = eina_list_remove_list(ls->tmp.expr_defs, ls->tmp.expr_defs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eolian_Binary_Operator
|
|
|
|
get_binop_id(int tok)
|
|
|
|
{
|
|
|
|
switch (tok)
|
|
|
|
{
|
2014-07-18 02:47:07 -07:00
|
|
|
case '+': return EOLIAN_BINOP_ADD;
|
|
|
|
case '-': return EOLIAN_BINOP_SUB;
|
|
|
|
case '*': return EOLIAN_BINOP_MUL;
|
|
|
|
case '/': return EOLIAN_BINOP_DIV;
|
|
|
|
case '%': return EOLIAN_BINOP_MOD;
|
2014-07-17 09:16:31 -07:00
|
|
|
|
2014-07-18 02:47:07 -07:00
|
|
|
case TOK_EQ: return EOLIAN_BINOP_EQ;
|
|
|
|
case TOK_NQ: return EOLIAN_BINOP_NQ;
|
2014-07-18 03:48:40 -07:00
|
|
|
case '>' : return EOLIAN_BINOP_GT;
|
|
|
|
case '<' : return EOLIAN_BINOP_LT;
|
2014-07-18 02:47:07 -07:00
|
|
|
case TOK_GE: return EOLIAN_BINOP_GE;
|
|
|
|
case TOK_LE: return EOLIAN_BINOP_LE;
|
2014-07-17 09:16:31 -07:00
|
|
|
|
2014-07-18 02:47:07 -07:00
|
|
|
case TOK_AND: return EOLIAN_BINOP_AND;
|
|
|
|
case TOK_OR : return EOLIAN_BINOP_OR;
|
2014-07-17 09:16:31 -07:00
|
|
|
|
2014-07-18 02:47:07 -07:00
|
|
|
case '&': return EOLIAN_BINOP_BAND;
|
|
|
|
case '|': return EOLIAN_BINOP_BOR;
|
|
|
|
case '^': return EOLIAN_BINOP_BXOR;
|
2014-07-17 09:16:31 -07:00
|
|
|
|
2014-07-18 02:47:07 -07:00
|
|
|
case TOK_LSH: return EOLIAN_BINOP_LSH;
|
|
|
|
case TOK_RSH: return EOLIAN_BINOP_RSH;
|
2014-07-17 09:16:31 -07:00
|
|
|
|
2017-01-13 06:15:10 -08:00
|
|
|
default: return EOLIAN_BINOP_INVALID;
|
2014-07-17 09:16:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eolian_Unary_Operator
|
|
|
|
get_unop_id(int tok)
|
|
|
|
{
|
|
|
|
switch (tok)
|
|
|
|
{
|
2014-07-18 02:47:07 -07:00
|
|
|
case '-': return EOLIAN_UNOP_UNM;
|
|
|
|
case '+': return EOLIAN_UNOP_UNP;
|
|
|
|
case '!': return EOLIAN_UNOP_NOT;
|
|
|
|
case '~': return EOLIAN_UNOP_BNOT;
|
2014-07-17 09:16:31 -07:00
|
|
|
|
2017-01-13 06:15:10 -08:00
|
|
|
default: return EOLIAN_UNOP_INVALID;
|
2014-07-17 09:16:31 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const int binprec[] = {
|
2017-01-13 06:15:10 -08:00
|
|
|
-1, /* invalid */
|
|
|
|
|
2014-07-17 09:16:31 -07:00
|
|
|
8, /* + */
|
|
|
|
8, /* - */
|
|
|
|
9, /* * */
|
|
|
|
9, /* / */
|
|
|
|
9, /* % */
|
|
|
|
|
|
|
|
3, /* == */
|
|
|
|
3, /* != */
|
|
|
|
3, /* > */
|
|
|
|
3, /* < */
|
|
|
|
3, /* >= */
|
|
|
|
3, /* <= */
|
|
|
|
|
|
|
|
2, /* && */
|
|
|
|
1, /* || */
|
|
|
|
|
|
|
|
6, /* & */
|
|
|
|
4, /* | */
|
|
|
|
5, /* ^ */
|
|
|
|
7, /* << */
|
|
|
|
7 /* >> */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define UNARY_PRECEDENCE 10
|
|
|
|
|
|
|
|
static Eolian_Expression *parse_expr_bin(Eo_Lexer *ls, int min_prec);
|
|
|
|
static Eolian_Expression *parse_expr(Eo_Lexer *ls);
|
|
|
|
|
|
|
|
static Eolian_Expression *
|
|
|
|
parse_expr_simple(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
Eolian_Expression *expr;
|
|
|
|
Eolian_Unary_Operator unop = get_unop_id(ls->t.token);
|
2017-01-13 06:15:10 -08:00
|
|
|
if (unop != EOLIAN_UNOP_INVALID)
|
2014-07-17 09:16:31 -07:00
|
|
|
{
|
2014-08-06 08:30:42 -07:00
|
|
|
int line = ls->line_number, col = ls->column;
|
2015-01-29 03:12:04 -08:00
|
|
|
eo_lexer_get(ls);
|
2014-07-17 09:16:31 -07:00
|
|
|
Eolian_Expression *exp = parse_expr_bin(ls, UNARY_PRECEDENCE);
|
|
|
|
pop_expr(ls);
|
|
|
|
expr = push_expr(ls);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(expr->base, ls, line, col);
|
2014-08-22 00:20:53 -07:00
|
|
|
expr->unop = unop;
|
2014-07-17 09:16:31 -07:00
|
|
|
expr->type = EOLIAN_EXPR_UNARY;
|
|
|
|
expr->expr = exp;
|
|
|
|
return expr;
|
|
|
|
}
|
|
|
|
switch (ls->t.token)
|
|
|
|
{
|
|
|
|
case TOK_NUMBER:
|
|
|
|
{
|
2014-08-06 08:30:42 -07:00
|
|
|
int line = ls->line_number, col = ls->column;
|
2014-07-17 09:16:31 -07:00
|
|
|
expr = push_expr(ls);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(expr->base, ls, line, col);
|
2014-07-17 09:16:31 -07:00
|
|
|
expr->type = ls->t.kw + 1; /* map Numbers from lexer to expr type */
|
2015-06-02 10:12:09 -07:00
|
|
|
memcpy(&expr->value, &ls->t.value, sizeof(expr->value));
|
2014-07-17 09:16:31 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TOK_STRING:
|
|
|
|
{
|
2014-08-06 08:30:42 -07:00
|
|
|
int line = ls->line_number, col = ls->column;
|
2014-07-17 09:16:31 -07:00
|
|
|
expr = push_expr(ls);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(expr->base, ls, line, col);
|
2014-07-17 09:16:31 -07:00
|
|
|
expr->type = EOLIAN_EXPR_STRING;
|
|
|
|
expr->value.s = eina_stringshare_ref(ls->t.value.s);
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
|
|
|
}
|
2014-08-07 07:15:07 -07:00
|
|
|
case TOK_CHAR:
|
|
|
|
{
|
|
|
|
int line = ls->line_number, col = ls->column;
|
|
|
|
expr = push_expr(ls);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(expr->base, ls, line, col);
|
2014-08-07 07:15:07 -07:00
|
|
|
expr->type = EOLIAN_EXPR_CHAR;
|
|
|
|
expr->value.c = ls->t.value.c;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
|
|
|
}
|
2014-07-17 09:16:31 -07:00
|
|
|
case TOK_VALUE:
|
|
|
|
{
|
2014-08-06 08:30:42 -07:00
|
|
|
int line = ls->line_number, col = ls->column;
|
2014-07-17 09:16:31 -07:00
|
|
|
switch (ls->t.kw)
|
|
|
|
{
|
|
|
|
case KW_true:
|
|
|
|
case KW_false:
|
|
|
|
{
|
|
|
|
expr = push_expr(ls);
|
|
|
|
expr->type = EOLIAN_EXPR_BOOL;
|
|
|
|
expr->value.b = (ls->t.kw == KW_true);
|
2014-08-07 07:15:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-07-17 09:16:31 -07:00
|
|
|
break;
|
2014-08-07 07:15:07 -07:00
|
|
|
}
|
|
|
|
case KW_null:
|
|
|
|
{
|
|
|
|
expr = push_expr(ls);
|
|
|
|
expr->type = EOLIAN_EXPR_NULL;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
|
|
|
}
|
2014-07-17 09:16:31 -07:00
|
|
|
default:
|
|
|
|
{
|
2014-08-12 05:11:13 -07:00
|
|
|
Eina_Strbuf *buf = push_strbuf(ls);
|
2014-07-17 09:16:31 -07:00
|
|
|
expr = push_expr(ls);
|
2015-05-12 08:15:29 -07:00
|
|
|
expr->type = EOLIAN_EXPR_NAME;
|
2014-08-12 05:11:13 -07:00
|
|
|
parse_name(ls, buf);
|
|
|
|
expr->value.s = eina_stringshare_add(eina_strbuf_string_get
|
|
|
|
(buf));
|
|
|
|
pop_strbuf(ls);
|
2014-07-17 09:16:31 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(expr->base, ls, line, col);
|
2014-08-07 07:15:07 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case '(':
|
|
|
|
{
|
|
|
|
int line = ls->line_number, col = ls->column;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
expr = parse_expr(ls);
|
|
|
|
check_match(ls, ')', '(', line, col);
|
2014-08-26 19:32:17 -07:00
|
|
|
break;
|
2014-07-17 09:16:31 -07:00
|
|
|
}
|
2014-08-07 07:15:07 -07:00
|
|
|
default:
|
|
|
|
expr = NULL; /* shut up compiler */
|
|
|
|
eo_lexer_syntax_error(ls, "unexpected symbol");
|
|
|
|
break;
|
2014-07-17 09:16:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return expr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eolian_Expression *
|
|
|
|
parse_expr_bin(Eo_Lexer *ls, int min_prec)
|
|
|
|
{
|
2014-08-06 08:30:42 -07:00
|
|
|
int line = ls->line_number, col = ls->column;
|
2014-07-17 09:16:31 -07:00
|
|
|
Eolian_Expression *lhs = parse_expr_simple(ls);
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
Eolian_Expression *rhs, *bin;
|
|
|
|
Eolian_Binary_Operator op = get_binop_id(ls->t.token);
|
2017-01-13 06:15:10 -08:00
|
|
|
int prec = binprec[op];
|
|
|
|
if ((op == EOLIAN_BINOP_INVALID) || (prec < 0) || (prec < min_prec))
|
2014-07-17 09:16:31 -07:00
|
|
|
break;
|
2014-08-12 08:29:02 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-07-17 09:16:31 -07:00
|
|
|
rhs = parse_expr_bin(ls, prec + 1);
|
|
|
|
pop_expr(ls);
|
|
|
|
pop_expr(ls);
|
|
|
|
bin = push_expr(ls);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(bin->base, ls, line, col);
|
2014-07-17 09:16:31 -07:00
|
|
|
bin->binop = op;
|
|
|
|
bin->type = EOLIAN_EXPR_BINARY;
|
|
|
|
bin->lhs = lhs;
|
|
|
|
bin->rhs = rhs;
|
|
|
|
lhs = bin;
|
|
|
|
}
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eolian_Expression *
|
|
|
|
parse_expr(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
return parse_expr_bin(ls, 1);
|
|
|
|
}
|
|
|
|
|
2016-06-30 06:04:03 -07:00
|
|
|
static Eolian_Type *parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref,
|
|
|
|
Eina_Bool allow_sarray);
|
2014-06-30 15:07:32 -07:00
|
|
|
|
2014-07-10 06:44:17 -07:00
|
|
|
static Eolian_Type *
|
2016-06-30 06:04:03 -07:00
|
|
|
parse_type(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
|
2014-06-30 15:07:32 -07:00
|
|
|
{
|
2014-07-22 07:27:11 -07:00
|
|
|
Eolian_Type *ret;
|
|
|
|
eo_lexer_context_push(ls);
|
2016-06-30 06:04:03 -07:00
|
|
|
ret = parse_type_void(ls, allow_ref, allow_sarray);
|
2014-06-30 15:07:32 -07:00
|
|
|
if (ret->type == EOLIAN_TYPE_VOID)
|
|
|
|
{
|
2014-07-22 07:27:11 -07:00
|
|
|
eo_lexer_context_restore(ls);
|
2014-06-30 15:07:32 -07:00
|
|
|
eo_lexer_syntax_error(ls, "non-void type expected");
|
|
|
|
}
|
2014-07-22 07:27:11 -07:00
|
|
|
eo_lexer_context_pop(ls);
|
2014-06-30 15:07:32 -07:00
|
|
|
return ret;
|
|
|
|
}
|
2014-06-30 13:52:57 -07:00
|
|
|
|
2014-07-10 06:44:17 -07:00
|
|
|
static void
|
2014-08-22 08:56:41 -07:00
|
|
|
_struct_field_free(Eolian_Struct_Type_Field *def)
|
2014-07-10 06:44:17 -07:00
|
|
|
{
|
2014-08-07 07:15:07 -07:00
|
|
|
if (def->base.file) eina_stringshare_del(def->base.file);
|
2014-08-22 08:56:41 -07:00
|
|
|
if (def->name) eina_stringshare_del(def->name);
|
2014-07-10 06:44:17 -07:00
|
|
|
database_type_del(def->type);
|
2015-06-03 07:35:13 -07:00
|
|
|
database_doc_del(def->doc);
|
2014-07-22 02:22:21 -07:00
|
|
|
free(def);
|
2014-07-10 06:44:17 -07:00
|
|
|
}
|
|
|
|
|
2016-03-01 07:37:57 -08:00
|
|
|
static Eolian_Typedecl *
|
2014-07-22 06:48:08 -07:00
|
|
|
parse_struct(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
|
2014-08-19 07:55:31 -07:00
|
|
|
int line, int column, const char *freefunc)
|
2014-07-08 07:02:36 -07:00
|
|
|
{
|
2014-07-22 06:48:08 -07:00
|
|
|
int bline = ls->line_number, bcolumn = ls->column;
|
2016-03-01 07:37:57 -08:00
|
|
|
Eolian_Typedecl *def = push_typedecl(ls);
|
2014-07-15 07:33:22 -07:00
|
|
|
def->is_extern = is_extern;
|
2014-11-21 06:12:40 -08:00
|
|
|
if (name) _fill_name(name, &def->full_name, &def->name, &def->namespaces);
|
2016-03-01 07:37:57 -08:00
|
|
|
def->type = EOLIAN_TYPEDECL_STRUCT;
|
2014-07-10 06:44:17 -07:00
|
|
|
def->fields = eina_hash_string_small_new(EINA_FREE_CB(_struct_field_free));
|
2014-08-19 07:55:31 -07:00
|
|
|
def->freefunc = freefunc;
|
2014-08-19 08:37:29 -07:00
|
|
|
pop_str(ls);
|
2014-07-08 07:44:42 -07:00
|
|
|
check_next(ls, '{');
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, def, doc);
|
2014-07-08 07:44:42 -07:00
|
|
|
while (ls->t.token != '}')
|
|
|
|
{
|
2014-07-08 08:42:33 -07:00
|
|
|
const char *fname;
|
2014-08-22 08:56:41 -07:00
|
|
|
Eolian_Struct_Type_Field *fdef;
|
2014-07-10 06:44:17 -07:00
|
|
|
Eolian_Type *tp;
|
2014-08-04 07:01:16 -07:00
|
|
|
int fline = ls->line_number, fcol = ls->column;
|
2014-07-08 07:44:42 -07:00
|
|
|
check(ls, TOK_VALUE);
|
2014-07-17 09:16:31 -07:00
|
|
|
if (eina_hash_find(def->fields, ls->t.value.s))
|
2014-07-08 08:17:44 -07:00
|
|
|
eo_lexer_syntax_error(ls, "double field definition");
|
2014-08-22 08:56:41 -07:00
|
|
|
fdef = calloc(1, sizeof(Eolian_Struct_Type_Field));
|
2014-07-17 09:16:31 -07:00
|
|
|
fname = eina_stringshare_ref(ls->t.value.s);
|
2014-08-15 03:07:06 -07:00
|
|
|
eina_hash_add(def->fields, fname, fdef);
|
2014-08-22 08:56:41 -07:00
|
|
|
def->field_list = eina_list_append(def->field_list, fdef);
|
2014-07-08 07:44:42 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ':');
|
2016-06-30 06:04:03 -07:00
|
|
|
tp = parse_type(ls, EINA_TRUE, EINA_TRUE);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(fdef->base, ls, fline, fcol);
|
2014-07-09 04:05:56 -07:00
|
|
|
fdef->type = tp;
|
2014-08-22 08:56:41 -07:00
|
|
|
fdef->name = eina_stringshare_ref(fname);
|
2014-07-09 03:18:21 -07:00
|
|
|
pop_type(ls);
|
2017-09-15 07:24:46 -07:00
|
|
|
if ((fdef->owned = (ls->t.kw == KW_at_owned)))
|
2017-09-15 06:51:25 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-07-08 07:44:42 -07:00
|
|
|
check_next(ls, ';');
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, fdef, doc);
|
2014-07-08 07:44:42 -07:00
|
|
|
}
|
2014-07-22 06:48:08 -07:00
|
|
|
check_match(ls, '}', '{', bline, bcolumn);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(def->base, ls, line, column);
|
2014-07-21 03:42:05 -07:00
|
|
|
if (name) database_struct_add(def);
|
2014-07-08 07:44:42 -07:00
|
|
|
return def;
|
2014-07-08 07:02:36 -07:00
|
|
|
}
|
|
|
|
|
2014-08-11 06:56:50 -07:00
|
|
|
static void
|
2014-08-22 08:56:41 -07:00
|
|
|
_enum_field_free(Eolian_Enum_Type_Field *def)
|
2014-08-11 06:56:50 -07:00
|
|
|
{
|
|
|
|
if (def->base.file) eina_stringshare_del(def->base.file);
|
2014-08-22 08:56:41 -07:00
|
|
|
if (def->name) eina_stringshare_del(def->name);
|
2014-08-11 06:56:50 -07:00
|
|
|
database_expr_del(def->value);
|
2015-06-03 07:35:13 -07:00
|
|
|
database_doc_del(def->doc);
|
2014-08-11 06:56:50 -07:00
|
|
|
free(def);
|
|
|
|
}
|
|
|
|
|
2016-03-01 07:37:57 -08:00
|
|
|
static Eolian_Typedecl *
|
2014-08-11 06:56:50 -07:00
|
|
|
parse_enum(Eo_Lexer *ls, const char *name, Eina_Bool is_extern,
|
|
|
|
int line, int column)
|
|
|
|
{
|
|
|
|
int bline = ls->line_number, bcolumn = ls->column;
|
2016-03-01 07:37:57 -08:00
|
|
|
Eolian_Typedecl *def = push_typedecl(ls);
|
2014-08-11 06:56:50 -07:00
|
|
|
def->is_extern = is_extern;
|
2014-11-21 06:12:40 -08:00
|
|
|
_fill_name(name, &def->full_name, &def->name, &def->namespaces);
|
2016-03-01 07:37:57 -08:00
|
|
|
def->type = EOLIAN_TYPEDECL_ENUM;
|
2014-08-11 06:56:50 -07:00
|
|
|
def->fields = eina_hash_string_small_new(EINA_FREE_CB(_enum_field_free));
|
|
|
|
check_next(ls, '{');
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, def, doc);
|
2014-08-11 06:56:50 -07:00
|
|
|
if (ls->t.token == TOK_VALUE && ls->t.kw == KW_legacy)
|
|
|
|
{
|
|
|
|
if (eo_lexer_lookahead(ls) == ':')
|
|
|
|
{
|
|
|
|
/* consume keyword */
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
/* consume colon */
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check(ls, TOK_VALUE);
|
|
|
|
def->legacy = eina_stringshare_ref(ls->t.value.s);
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ';');
|
|
|
|
}
|
|
|
|
}
|
2015-05-13 10:10:02 -07:00
|
|
|
Eolian_Enum_Type_Field *prev_fl = NULL;
|
|
|
|
int fl_nadd = 0;
|
2014-08-11 06:56:50 -07:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
const char *fname;
|
2014-08-22 08:56:41 -07:00
|
|
|
Eolian_Enum_Type_Field *fdef;
|
2014-08-11 06:56:50 -07:00
|
|
|
int fline = ls->line_number, fcol = ls->column;
|
|
|
|
check(ls, TOK_VALUE);
|
|
|
|
if (eina_hash_find(def->fields, ls->t.value.s))
|
|
|
|
eo_lexer_syntax_error(ls, "double field definition");
|
2014-08-22 08:56:41 -07:00
|
|
|
fdef = calloc(1, sizeof(Eolian_Enum_Type_Field));
|
2014-08-11 06:56:50 -07:00
|
|
|
fname = eina_stringshare_ref(ls->t.value.s);
|
2014-08-15 03:07:06 -07:00
|
|
|
eina_hash_add(def->fields, fname, fdef);
|
2014-08-22 08:56:41 -07:00
|
|
|
def->field_list = eina_list_append(def->field_list, fdef);
|
2014-08-11 06:56:50 -07:00
|
|
|
eo_lexer_get(ls);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(fdef->base, ls, fline, fcol);
|
2015-05-12 09:04:54 -07:00
|
|
|
fdef->base_enum = def;
|
2014-08-22 08:56:41 -07:00
|
|
|
fdef->name = eina_stringshare_ref(fname);
|
2014-08-11 06:56:50 -07:00
|
|
|
if (ls->t.token != '=')
|
|
|
|
{
|
2015-05-13 10:10:02 -07:00
|
|
|
if (!prev_fl)
|
2014-08-11 06:56:50 -07:00
|
|
|
{
|
2015-05-13 10:10:02 -07:00
|
|
|
Eolian_Expression *eexp = push_expr(ls);
|
|
|
|
FILL_BASE(eexp->base, ls, -1, -1);
|
|
|
|
eexp->type = EOLIAN_EXPR_INT;
|
|
|
|
eexp->value.i = 0;
|
|
|
|
fdef->value = eexp;
|
2015-05-13 09:56:18 -07:00
|
|
|
fdef->is_public_value = EINA_TRUE;
|
2014-08-11 06:56:50 -07:00
|
|
|
pop_expr(ls);
|
2015-05-13 10:10:02 -07:00
|
|
|
prev_fl = fdef;
|
|
|
|
fl_nadd = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Eolian_Expression *rhs = push_expr(ls),
|
|
|
|
*bin = push_expr(ls);
|
|
|
|
FILL_BASE(rhs->base, ls, -1, -1);
|
|
|
|
FILL_BASE(bin->base, ls, -1, -1);
|
|
|
|
|
|
|
|
rhs->type = EOLIAN_EXPR_INT;
|
|
|
|
rhs->value.i = ++fl_nadd;
|
|
|
|
|
|
|
|
bin->type = EOLIAN_EXPR_BINARY;
|
|
|
|
bin->binop = EOLIAN_BINOP_ADD;
|
|
|
|
bin->lhs = prev_fl->value;
|
|
|
|
bin->rhs = rhs;
|
|
|
|
bin->weak_lhs = EINA_TRUE;
|
|
|
|
|
|
|
|
fdef->value = bin;
|
2014-08-11 06:56:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ls->expr_mode = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
fdef->value = parse_expr(ls);
|
2015-05-13 09:56:18 -07:00
|
|
|
fdef->is_public_value = EINA_TRUE;
|
2014-08-11 06:56:50 -07:00
|
|
|
ls->expr_mode = EINA_FALSE;
|
2015-05-13 10:10:02 -07:00
|
|
|
prev_fl = fdef;
|
|
|
|
fl_nadd = 0;
|
2014-08-11 06:56:50 -07:00
|
|
|
pop_expr(ls);
|
|
|
|
}
|
|
|
|
Eina_Bool want_next = (ls->t.token == ',');
|
|
|
|
if (want_next)
|
|
|
|
eo_lexer_get(ls);
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, fdef, doc);
|
2015-07-03 07:19:12 -07:00
|
|
|
if (!want_next || ls->t.token == '}')
|
2014-08-11 06:56:50 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
check_match(ls, '}', '{', bline, bcolumn);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(def->base, ls, line, column);
|
2014-08-12 06:25:53 -07:00
|
|
|
if (name) database_enum_add(def);
|
2014-08-11 06:56:50 -07:00
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
2014-08-19 07:55:31 -07:00
|
|
|
static void
|
2015-05-12 08:15:29 -07:00
|
|
|
parse_struct_attrs(Eo_Lexer *ls, Eina_Bool is_enum, Eina_Bool *is_extern,
|
|
|
|
const char **freefunc)
|
2014-08-19 07:55:31 -07:00
|
|
|
{
|
|
|
|
Eina_Bool has_extern = EINA_FALSE, has_free = EINA_FALSE;
|
|
|
|
*freefunc = NULL;
|
|
|
|
*is_extern = EINA_FALSE;
|
|
|
|
for (;;) switch (ls->t.kw)
|
|
|
|
{
|
|
|
|
case KW_at_extern:
|
|
|
|
CASE_LOCK(ls, extern, "@extern qualifier")
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
*is_extern = EINA_TRUE;
|
|
|
|
break;
|
|
|
|
case KW_at_free:
|
|
|
|
{
|
|
|
|
CASE_LOCK(ls, free, "@free qualifier")
|
|
|
|
if (is_enum)
|
|
|
|
eo_lexer_syntax_error(ls, "enums cannot have @free");
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
int pline = ls->line_number, pcol = ls->column;
|
|
|
|
check_next(ls, '(');
|
|
|
|
check(ls, TOK_VALUE);
|
2014-08-19 08:37:29 -07:00
|
|
|
*freefunc = push_str(ls, ls->t.value.s);
|
2014-08-19 07:55:31 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_match(ls, ')', '(', pline, pcol);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-26 03:06:54 -07:00
|
|
|
static void
|
2015-05-22 07:03:38 -07:00
|
|
|
_parse_dep(Eo_Lexer *ls, const char *fname, const char *name)
|
2014-08-26 03:06:54 -07:00
|
|
|
{
|
2015-05-22 07:03:38 -07:00
|
|
|
if (eina_hash_find(_parsingeos, fname))
|
2016-12-27 12:53:00 -08:00
|
|
|
return;
|
2015-05-22 09:32:21 -07:00
|
|
|
if (!eo_parser_database_fill(fname, EINA_FALSE))
|
2015-05-22 07:03:38 -07:00
|
|
|
{
|
|
|
|
char buf[PATH_MAX];
|
|
|
|
eo_lexer_context_restore(ls);
|
|
|
|
snprintf(buf, sizeof(buf), "error parsing dependency '%s'", name);
|
|
|
|
eo_lexer_syntax_error(ls, buf);
|
|
|
|
}
|
2014-08-26 03:06:54 -07:00
|
|
|
}
|
|
|
|
|
2014-08-11 06:56:50 -07:00
|
|
|
static Eolian_Type *
|
2016-06-30 06:04:03 -07:00
|
|
|
parse_type_void(Eo_Lexer *ls, Eina_Bool allow_ref, Eina_Bool allow_sarray)
|
2014-06-26 03:51:08 -07:00
|
|
|
{
|
2014-07-10 06:44:17 -07:00
|
|
|
Eolian_Type *def;
|
2014-07-21 07:11:19 -07:00
|
|
|
Eina_Strbuf *buf;
|
2014-08-04 07:01:16 -07:00
|
|
|
int line = ls->line_number, col = ls->column;
|
2014-06-26 03:51:08 -07:00
|
|
|
switch (ls->t.kw)
|
|
|
|
{
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_const:
|
|
|
|
{
|
2014-08-21 01:25:19 -07:00
|
|
|
int pline, pcol;
|
2014-07-01 10:25:17 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-08-21 01:25:19 -07:00
|
|
|
pline = ls->line_number;
|
|
|
|
pcol = ls->column;
|
2014-07-01 10:25:17 -07:00
|
|
|
check_next(ls, '(');
|
2016-06-30 06:04:03 -07:00
|
|
|
def = parse_type_void(ls, allow_ref, EINA_FALSE);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(def->base, ls, line, col);
|
2014-07-01 10:25:17 -07:00
|
|
|
def->is_const = EINA_TRUE;
|
2014-08-21 01:25:19 -07:00
|
|
|
check_match(ls, ')', '(', pline, pcol);
|
2016-11-10 07:20:19 -08:00
|
|
|
return def;
|
2014-07-01 10:25:17 -07:00
|
|
|
}
|
2016-11-02 05:06:38 -07:00
|
|
|
case KW_ptr:
|
2016-06-08 07:49:09 -07:00
|
|
|
{
|
|
|
|
int pline, pcol;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
pline = ls->line_number;
|
|
|
|
pcol = ls->column;
|
|
|
|
check_next(ls, '(');
|
2016-06-30 06:04:03 -07:00
|
|
|
def = parse_type_void(ls, EINA_FALSE, EINA_FALSE);
|
2016-06-08 07:49:09 -07:00
|
|
|
FILL_BASE(def->base, ls, line, col);
|
2016-11-03 06:21:57 -07:00
|
|
|
def->is_ptr = EINA_TRUE;
|
2016-06-08 07:49:09 -07:00
|
|
|
check_match(ls, ')', '(', pline, pcol);
|
2016-11-10 07:20:19 -08:00
|
|
|
return def;
|
2016-06-08 07:49:09 -07:00
|
|
|
}
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_own:
|
|
|
|
{
|
2014-08-04 07:01:16 -07:00
|
|
|
int pline, pcolumn;
|
2014-07-01 10:25:17 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-08-04 07:01:16 -07:00
|
|
|
pline = ls->line_number;
|
|
|
|
pcolumn = ls->column;
|
2014-07-01 10:25:17 -07:00
|
|
|
check_next(ls, '(');
|
2016-06-30 06:04:03 -07:00
|
|
|
def = parse_type_void(ls, allow_ref, EINA_FALSE);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(def->base, ls, line, col);
|
2014-07-01 10:25:17 -07:00
|
|
|
def->is_own = EINA_TRUE;
|
2014-08-04 07:01:16 -07:00
|
|
|
check_match(ls, ')', '(', pline, pcolumn);
|
2016-11-10 07:20:19 -08:00
|
|
|
return def;
|
2014-07-01 10:25:17 -07:00
|
|
|
}
|
2014-08-19 07:55:31 -07:00
|
|
|
case KW_free:
|
|
|
|
{
|
|
|
|
int pline, pcolumn;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
pline = ls->line_number;
|
|
|
|
pcolumn = ls->column;
|
|
|
|
check_next(ls, '(');
|
2016-06-30 06:04:03 -07:00
|
|
|
def = parse_type_void(ls, allow_ref, EINA_FALSE);
|
2014-08-19 07:55:31 -07:00
|
|
|
check_next(ls, ',');
|
|
|
|
check(ls, TOK_VALUE);
|
|
|
|
def->freefunc = eina_stringshare_ref(ls->t.value.s);
|
|
|
|
eo_lexer_get(ls);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(def->base, ls, line, col);
|
2014-08-19 07:55:31 -07:00
|
|
|
check_match(ls, ')', '(', pline, pcolumn);
|
2016-11-10 07:20:19 -08:00
|
|
|
return def;
|
2014-08-19 07:55:31 -07:00
|
|
|
}
|
2014-07-01 10:25:17 -07:00
|
|
|
default:
|
|
|
|
break;
|
2014-06-26 03:51:08 -07:00
|
|
|
}
|
2014-07-09 03:18:21 -07:00
|
|
|
def = push_type(ls);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(def->base, ls, line, col);
|
2014-07-15 09:06:18 -07:00
|
|
|
if (ls->t.kw == KW_void)
|
2014-07-21 07:11:19 -07:00
|
|
|
{
|
|
|
|
def->type = EOLIAN_TYPE_VOID;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
2015-11-19 06:04:37 -08:00
|
|
|
else if (ls->t.kw == KW___undefined_type)
|
|
|
|
{
|
|
|
|
def->type = EOLIAN_TYPE_UNDEFINED;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
2016-06-30 06:04:03 -07:00
|
|
|
else if (ls->t.kw == KW_static_array)
|
|
|
|
{
|
|
|
|
if (!allow_sarray)
|
|
|
|
eo_lexer_syntax_error(ls, "static arrays not allowed in this context");
|
|
|
|
def->type = EOLIAN_TYPE_STATIC_ARRAY;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, '<');
|
|
|
|
def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
|
|
|
|
pop_type(ls);
|
|
|
|
check_next(ls, ',');
|
|
|
|
check(ls, TOK_NUMBER);
|
|
|
|
eo_lexer_context_push(ls);
|
|
|
|
if (ls->t.kw == NUM_FLOAT || ls->t.kw == NUM_DOUBLE)
|
|
|
|
{
|
|
|
|
eo_lexer_context_restore(ls);
|
|
|
|
eo_lexer_syntax_error(ls, "integer expected");
|
|
|
|
}
|
|
|
|
eo_lexer_context_pop(ls);
|
|
|
|
switch (ls->t.kw)
|
|
|
|
{
|
|
|
|
case NUM_INT : def->static_size = ls->t.value.i; break;
|
|
|
|
case NUM_UINT : def->static_size = ls->t.value.u; break;
|
|
|
|
case NUM_LONG : def->static_size = ls->t.value.l; break;
|
|
|
|
case NUM_ULONG : def->static_size = ls->t.value.ul; break;
|
|
|
|
case NUM_LLONG : def->static_size = ls->t.value.ll; break;
|
|
|
|
case NUM_ULLONG: def->static_size = ls->t.value.ull; break;
|
|
|
|
default:
|
|
|
|
eo_lexer_syntax_error(ls, "wrong type, internal error");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, '>');
|
|
|
|
}
|
|
|
|
else if (ls->t.kw == KW_terminated_array)
|
|
|
|
{
|
|
|
|
def->type = EOLIAN_TYPE_TERMINATED_ARRAY;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, '<');
|
|
|
|
def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
|
|
|
|
pop_type(ls);
|
|
|
|
check_next(ls, '>');
|
|
|
|
}
|
2014-06-30 15:07:32 -07:00
|
|
|
else
|
|
|
|
{
|
2014-09-08 06:52:49 -07:00
|
|
|
int tpid = ls->t.kw;
|
2014-07-15 09:06:18 -07:00
|
|
|
def->type = EOLIAN_TYPE_REGULAR;
|
2014-06-30 15:07:32 -07:00
|
|
|
check(ls, TOK_VALUE);
|
2016-06-30 06:04:03 -07:00
|
|
|
if (eo_lexer_is_type_keyword(ls->t.kw))
|
2014-07-21 07:11:19 -07:00
|
|
|
{
|
2014-11-21 06:12:40 -08:00
|
|
|
_fill_name(eina_stringshare_ref(ls->t.value.s), &def->full_name,
|
|
|
|
&def->name, &def->namespaces);
|
2014-07-21 07:11:19 -07:00
|
|
|
eo_lexer_get(ls);
|
2016-06-29 15:00:17 -07:00
|
|
|
if (tpid >= KW_accessor && tpid <= KW_future)
|
2014-09-08 06:52:49 -07:00
|
|
|
{
|
2015-05-14 03:27:00 -07:00
|
|
|
int bline = ls->line_number, bcol = ls->column;
|
2014-09-08 06:52:49 -07:00
|
|
|
def->type = EOLIAN_TYPE_COMPLEX;
|
2015-05-14 03:27:00 -07:00
|
|
|
check_next(ls, '<');
|
2017-05-04 06:27:17 -07:00
|
|
|
if (tpid == KW_future)
|
|
|
|
def->base_type = parse_type_void(ls, EINA_FALSE, EINA_FALSE);
|
|
|
|
else
|
|
|
|
def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
|
2015-05-14 03:27:00 -07:00
|
|
|
pop_type(ls);
|
2017-09-15 07:24:46 -07:00
|
|
|
if ((def->base_type->owned = (ls->t.kw == KW_at_owned)))
|
|
|
|
eo_lexer_get(ls);
|
2015-05-14 03:27:00 -07:00
|
|
|
if (tpid == KW_hash)
|
2014-09-08 06:52:49 -07:00
|
|
|
{
|
2015-05-14 03:27:00 -07:00
|
|
|
check_next(ls, ',');
|
2016-06-30 06:04:03 -07:00
|
|
|
def->base_type->next_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
|
2014-09-08 06:52:49 -07:00
|
|
|
pop_type(ls);
|
2017-09-15 07:24:46 -07:00
|
|
|
if ((def->base_type->next_type->owned = (ls->t.kw == KW_at_owned)))
|
|
|
|
eo_lexer_get(ls);
|
2014-09-08 06:52:49 -07:00
|
|
|
}
|
2016-11-07 11:41:40 -08:00
|
|
|
else if((tpid == KW_future) && test_next(ls, ','))
|
2016-05-23 11:58:11 -07:00
|
|
|
{
|
2017-05-04 06:27:17 -07:00
|
|
|
def->base_type->next_type = parse_type_void(ls, EINA_FALSE, EINA_FALSE);
|
2016-05-23 11:58:11 -07:00
|
|
|
pop_type(ls);
|
|
|
|
}
|
2015-05-14 03:27:00 -07:00
|
|
|
check_match(ls, '>', '<', bline, bcol);
|
2014-09-08 06:52:49 -07:00
|
|
|
}
|
2014-07-21 07:11:19 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-07-30 07:35:57 -07:00
|
|
|
const char *bnm, *nm;
|
|
|
|
char *fnm;
|
2014-07-21 07:11:19 -07:00
|
|
|
buf = push_strbuf(ls);
|
2015-05-22 07:03:38 -07:00
|
|
|
eo_lexer_context_push(ls);
|
2014-07-21 07:11:19 -07:00
|
|
|
parse_name(ls, buf);
|
2014-07-30 03:57:11 -07:00
|
|
|
nm = eina_strbuf_string_get(buf);
|
2014-08-08 07:19:52 -07:00
|
|
|
bnm = eina_stringshare_ref(ls->filename);
|
2014-07-30 07:35:57 -07:00
|
|
|
fnm = database_class_to_filename(nm);
|
2014-08-01 05:59:46 -07:00
|
|
|
if (!compare_class_file(bnm, fnm))
|
2014-07-30 03:57:11 -07:00
|
|
|
{
|
2014-07-30 07:35:57 -07:00
|
|
|
const char *fname = eina_hash_find(_filenames, fnm);
|
|
|
|
eina_stringshare_del(bnm);
|
|
|
|
free(fnm);
|
|
|
|
if (fname)
|
2014-07-30 03:57:11 -07:00
|
|
|
{
|
2015-05-22 07:03:38 -07:00
|
|
|
_parse_dep(ls, fname, nm);
|
2014-07-30 07:35:57 -07:00
|
|
|
def->type = EOLIAN_TYPE_CLASS;
|
2014-07-30 03:57:11 -07:00
|
|
|
}
|
|
|
|
}
|
2014-07-30 07:35:57 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
eina_stringshare_del(bnm);
|
|
|
|
free(fnm);
|
|
|
|
def->type = EOLIAN_TYPE_CLASS;
|
|
|
|
}
|
2014-11-21 06:12:40 -08:00
|
|
|
_fill_name(eina_stringshare_add(nm), &def->full_name, &def->name,
|
|
|
|
&def->namespaces);
|
2015-05-22 07:03:38 -07:00
|
|
|
eo_lexer_context_pop(ls);
|
2014-07-21 07:11:19 -07:00
|
|
|
pop_strbuf(ls);
|
|
|
|
}
|
2014-06-30 15:07:32 -07:00
|
|
|
}
|
2014-06-27 06:47:40 -07:00
|
|
|
return def;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
2016-03-01 07:37:57 -08:00
|
|
|
static Eolian_Typedecl *
|
2014-06-18 03:25:07 -07:00
|
|
|
parse_typedef(Eo_Lexer *ls)
|
|
|
|
{
|
2015-05-15 07:10:58 -07:00
|
|
|
Eolian_Declaration *decl;
|
2016-03-01 07:37:57 -08:00
|
|
|
Eolian_Typedecl *def = push_typedecl(ls);
|
2014-08-19 07:55:31 -07:00
|
|
|
Eina_Bool has_extern;
|
|
|
|
const char *freefunc;
|
2014-07-21 08:53:25 -07:00
|
|
|
Eina_Strbuf *buf;
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2015-05-12 08:15:29 -07:00
|
|
|
parse_struct_attrs(ls, EINA_FALSE, &has_extern, &freefunc);
|
2014-08-19 07:55:31 -07:00
|
|
|
def->freefunc = freefunc;
|
2014-08-19 08:37:29 -07:00
|
|
|
pop_str(ls);
|
2016-03-01 07:37:57 -08:00
|
|
|
def->type = EOLIAN_TYPEDECL_ALIAS;
|
2014-08-19 07:55:31 -07:00
|
|
|
def->is_extern = has_extern;
|
2014-07-21 08:53:25 -07:00
|
|
|
buf = push_strbuf(ls);
|
2014-07-22 07:27:11 -07:00
|
|
|
eo_lexer_context_push(ls);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(def->base, ls, ls->line_number, ls->column);
|
2014-07-21 08:53:25 -07:00
|
|
|
parse_name(ls, buf);
|
2014-11-21 06:12:40 -08:00
|
|
|
_fill_name(eina_stringshare_add(eina_strbuf_string_get(buf)),
|
|
|
|
&def->full_name, &def->name, &def->namespaces);
|
2015-05-15 07:10:58 -07:00
|
|
|
decl = (Eolian_Declaration *)eina_hash_find(_decls, def->full_name);
|
|
|
|
if (decl)
|
2014-07-21 08:53:25 -07:00
|
|
|
{
|
2014-07-22 07:27:11 -07:00
|
|
|
eo_lexer_context_restore(ls);
|
2015-05-15 07:10:58 -07:00
|
|
|
redef_error(ls, decl, EOLIAN_DECL_ALIAS);
|
2014-07-21 08:53:25 -07:00
|
|
|
}
|
2014-07-22 07:27:11 -07:00
|
|
|
eo_lexer_context_pop(ls);
|
2014-08-08 07:57:39 -07:00
|
|
|
check_next(ls, ':');
|
2016-06-30 06:04:03 -07:00
|
|
|
def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
|
2014-07-09 03:18:21 -07:00
|
|
|
pop_type(ls);
|
2014-06-18 03:25:07 -07:00
|
|
|
check_next(ls, ';');
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, def, doc);
|
2017-07-06 19:48:25 -07:00
|
|
|
pop_strbuf(ls);
|
2014-07-21 08:53:25 -07:00
|
|
|
return def;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
2014-08-08 07:57:39 -07:00
|
|
|
static Eolian_Variable *
|
|
|
|
parse_variable(Eo_Lexer *ls, Eina_Bool global)
|
|
|
|
{
|
2015-05-15 07:10:58 -07:00
|
|
|
Eolian_Declaration *decl;
|
2014-09-12 07:01:10 -07:00
|
|
|
Eolian_Variable *def = calloc(1, sizeof(Eolian_Variable));
|
2014-08-08 07:57:39 -07:00
|
|
|
Eina_Strbuf *buf;
|
2014-09-12 07:01:10 -07:00
|
|
|
ls->tmp.var = def;
|
2014-08-08 07:57:39 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
if (ls->t.kw == KW_at_extern)
|
|
|
|
{
|
2016-10-19 06:24:26 -07:00
|
|
|
def->is_extern = EINA_TRUE;
|
2014-08-08 07:57:39 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
|
|
|
def->type = global ? EOLIAN_VAR_GLOBAL : EOLIAN_VAR_CONSTANT;
|
|
|
|
buf = push_strbuf(ls);
|
|
|
|
eo_lexer_context_push(ls);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(def->base, ls, ls->line_number, ls->column);
|
2014-08-08 07:57:39 -07:00
|
|
|
parse_name(ls, buf);
|
2014-11-21 06:12:40 -08:00
|
|
|
_fill_name(eina_stringshare_add(eina_strbuf_string_get(buf)),
|
|
|
|
&def->full_name, &def->name, &def->namespaces);
|
2015-05-15 07:10:58 -07:00
|
|
|
decl = (Eolian_Declaration *)eina_hash_find(_decls, def->full_name);
|
|
|
|
if (decl)
|
|
|
|
{
|
|
|
|
eo_lexer_context_restore(ls);
|
|
|
|
redef_error(ls, decl, EOLIAN_DECL_VAR);
|
|
|
|
}
|
|
|
|
eo_lexer_context_pop(ls);
|
2014-08-08 07:57:39 -07:00
|
|
|
check_next(ls, ':');
|
2016-06-30 06:04:03 -07:00
|
|
|
def->base_type = parse_type(ls, EINA_FALSE, EINA_FALSE);
|
2014-08-08 07:57:39 -07:00
|
|
|
pop_type(ls);
|
2016-10-19 06:24:26 -07:00
|
|
|
/* constants are required to have a value */
|
|
|
|
if (!global)
|
|
|
|
check(ls, '=');
|
|
|
|
/* globals can optionally have a value */
|
|
|
|
if (ls->t.token == '=')
|
2014-08-08 07:57:39 -07:00
|
|
|
{
|
|
|
|
ls->expr_mode = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
def->value = parse_expr(ls);
|
|
|
|
ls->expr_mode = EINA_FALSE;
|
2014-08-11 06:56:50 -07:00
|
|
|
pop_expr(ls);
|
2014-08-08 07:57:39 -07:00
|
|
|
}
|
|
|
|
check_next(ls, ';');
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, def, doc);
|
2017-07-06 19:48:25 -07:00
|
|
|
pop_strbuf(ls);
|
2014-08-08 07:57:39 -07:00
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
2014-09-10 08:17:47 -07:00
|
|
|
typedef struct _Eo_Ret_Def
|
|
|
|
{
|
|
|
|
Eolian_Type *type;
|
2015-06-03 07:35:13 -07:00
|
|
|
Eolian_Documentation *doc;
|
2014-09-10 08:17:47 -07:00
|
|
|
Eolian_Expression *default_ret_val;
|
2016-06-07 06:59:36 -07:00
|
|
|
Eina_Bool warn_unused: 1;
|
2017-09-15 06:51:25 -07:00
|
|
|
Eina_Bool owned: 1;
|
2014-09-10 08:17:47 -07:00
|
|
|
} Eo_Ret_Def;
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
static void
|
2017-09-15 06:54:48 -07:00
|
|
|
parse_return(Eo_Lexer *ls, Eo_Ret_Def *ret, Eina_Bool allow_void,
|
|
|
|
Eina_Bool allow_def, Eina_Bool is_funcptr)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
|
|
|
eo_lexer_get(ls);
|
2014-08-07 08:58:45 -07:00
|
|
|
check_next(ls, ':');
|
2014-06-30 15:13:04 -07:00
|
|
|
if (allow_void)
|
2016-06-30 06:04:03 -07:00
|
|
|
ret->type = parse_type_void(ls, EINA_TRUE, EINA_FALSE);
|
2014-06-30 15:13:04 -07:00
|
|
|
else
|
2016-06-30 06:04:03 -07:00
|
|
|
ret->type = parse_type(ls, EINA_TRUE, EINA_FALSE);
|
2015-06-03 07:35:13 -07:00
|
|
|
ret->doc = NULL;
|
2014-09-10 08:17:47 -07:00
|
|
|
ret->default_ret_val = NULL;
|
|
|
|
ret->warn_unused = EINA_FALSE;
|
2017-09-15 06:51:25 -07:00
|
|
|
ret->owned = EINA_FALSE;
|
2017-08-28 08:22:09 -07:00
|
|
|
if (allow_def && (ls->t.token == '('))
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-07-02 16:00:02 -07:00
|
|
|
int line = ls->line_number, col = ls->column;
|
2014-08-08 03:32:07 -07:00
|
|
|
ls->expr_mode = EINA_TRUE;
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-08-07 07:15:07 -07:00
|
|
|
ret->default_ret_val = parse_expr(ls);
|
2014-08-08 03:32:07 -07:00
|
|
|
ls->expr_mode = EINA_FALSE;
|
2014-07-02 16:00:02 -07:00
|
|
|
check_match(ls, ')', '(', line, col);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
2017-09-15 06:51:25 -07:00
|
|
|
Eina_Bool has_warn_unused = EINA_FALSE, has_owned = EINA_FALSE;
|
2017-09-15 06:54:48 -07:00
|
|
|
if (!is_funcptr) for (;;) switch (ls->t.kw)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2016-06-07 06:59:36 -07:00
|
|
|
case KW_at_warn_unused:
|
|
|
|
CASE_LOCK(ls, warn_unused, "warn_unused qualifier");
|
2014-06-18 03:25:07 -07:00
|
|
|
ret->warn_unused = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
2016-06-07 06:59:36 -07:00
|
|
|
break;
|
2017-09-15 06:51:25 -07:00
|
|
|
case KW_at_owned:
|
|
|
|
CASE_LOCK(ls, owned, "owned qualifier");
|
|
|
|
ret->owned = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2016-06-07 06:59:36 -07:00
|
|
|
default:
|
|
|
|
goto end;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
2016-06-07 06:59:36 -07:00
|
|
|
end:
|
2014-06-18 03:25:07 -07:00
|
|
|
check_next(ls, ';');
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, ret, doc);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-12 05:35:48 -07:00
|
|
|
parse_param(Eo_Lexer *ls, Eina_List **params, Eina_Bool allow_inout,
|
|
|
|
Eina_Bool is_vals)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2015-02-12 03:14:45 -08:00
|
|
|
Eina_Bool has_nonull = EINA_FALSE, has_optional = EINA_FALSE,
|
2017-09-15 06:51:25 -07:00
|
|
|
has_nullable = EINA_FALSE, has_owned = EINA_FALSE;
|
2014-09-10 06:24:41 -07:00
|
|
|
Eolian_Function_Parameter *par = calloc(1, sizeof(Eolian_Function_Parameter));
|
2017-01-13 06:15:10 -08:00
|
|
|
par->param_dir = EOLIAN_IN_PARAM;
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(par->base, ls, ls->line_number, ls->column);
|
2014-09-12 05:35:48 -07:00
|
|
|
*params = eina_list_append(*params, par);
|
2016-06-06 07:22:56 -07:00
|
|
|
if (allow_inout && ls->t.kw == KW_at_in)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2016-06-06 07:22:56 -07:00
|
|
|
par->param_dir = EOLIAN_IN_PARAM;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
|
|
|
else if (allow_inout && ls->t.kw == KW_at_out)
|
|
|
|
{
|
|
|
|
par->param_dir = EOLIAN_OUT_PARAM;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
|
|
|
else if (allow_inout && ls->t.kw == KW_at_inout)
|
|
|
|
{
|
|
|
|
par->param_dir = EOLIAN_INOUT_PARAM;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
|
|
|
else par->param_dir = EOLIAN_IN_PARAM;
|
2015-05-18 08:13:08 -07:00
|
|
|
check(ls, TOK_VALUE);
|
|
|
|
par->name = eina_stringshare_ref(ls->t.value.s);
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ':');
|
2014-09-10 06:24:41 -07:00
|
|
|
if (par->param_dir == EOLIAN_OUT_PARAM || par->param_dir == EOLIAN_INOUT_PARAM)
|
2016-06-30 06:04:03 -07:00
|
|
|
par->type = parse_type_void(ls, EINA_TRUE, EINA_FALSE);
|
2014-06-30 15:21:36 -07:00
|
|
|
else
|
2016-06-30 06:04:03 -07:00
|
|
|
par->type = parse_type(ls, EINA_TRUE, EINA_FALSE);
|
2014-07-09 03:18:21 -07:00
|
|
|
pop_type(ls);
|
2014-09-10 06:24:41 -07:00
|
|
|
if ((is_vals || (par->param_dir == EOLIAN_OUT_PARAM)) && (ls->t.token == '('))
|
2014-09-02 02:47:38 -07:00
|
|
|
{
|
|
|
|
int line = ls->line_number, col = ls->column;
|
|
|
|
ls->expr_mode = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
par->value = parse_expr(ls);
|
|
|
|
ls->expr_mode = EINA_FALSE;
|
|
|
|
pop_expr(ls);
|
|
|
|
check_match(ls, ')', '(', line, col);
|
|
|
|
}
|
2015-02-12 03:14:45 -08:00
|
|
|
for (;;) switch (ls->t.kw)
|
|
|
|
{
|
|
|
|
case KW_at_nonull:
|
|
|
|
if (has_nullable)
|
|
|
|
eo_lexer_syntax_error(ls, "both nullable and nonull specified");
|
|
|
|
CASE_LOCK(ls, nonull, "nonull qualifier")
|
|
|
|
par->nonull = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
|
|
|
case KW_at_optional:
|
|
|
|
CASE_LOCK(ls, optional, "optional qualifier");
|
2015-02-12 03:32:34 -08:00
|
|
|
par->optional = EINA_TRUE;
|
2015-02-12 03:14:45 -08:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
|
|
|
case KW_at_nullable:
|
2015-02-12 03:19:24 -08:00
|
|
|
if (has_nonull)
|
2015-02-12 03:14:45 -08:00
|
|
|
eo_lexer_syntax_error(ls, "both nullable and nonull specified");
|
2015-05-08 06:00:07 -07:00
|
|
|
CASE_LOCK(ls, nullable, "nullable qualifier");
|
2015-02-12 03:32:34 -08:00
|
|
|
par->nullable = EINA_TRUE;
|
2015-02-12 03:14:45 -08:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2017-09-15 06:51:25 -07:00
|
|
|
case KW_at_owned:
|
|
|
|
CASE_LOCK(ls, owned, "owned qualifier");
|
|
|
|
par->owned = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2015-02-12 03:14:45 -08:00
|
|
|
default:
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
end:
|
2014-06-18 03:25:07 -07:00
|
|
|
check_next(ls, ';');
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, par, doc);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-12 05:30:24 -07:00
|
|
|
parse_legacy(Eo_Lexer *ls, const char **out)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
|
|
|
eo_lexer_get(ls);
|
2014-08-07 08:58:45 -07:00
|
|
|
check_next(ls, ':');
|
2014-06-18 03:25:07 -07:00
|
|
|
check(ls, TOK_VALUE);
|
2014-09-12 05:30:24 -07:00
|
|
|
*out = eina_stringshare_ref(ls->t.value.s);
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ';');
|
|
|
|
}
|
|
|
|
|
2015-05-20 09:42:00 -07:00
|
|
|
static void
|
|
|
|
parse_params(Eo_Lexer *ls, Eina_List **params, Eina_Bool allow_inout,
|
|
|
|
Eina_Bool is_vals)
|
|
|
|
{
|
|
|
|
int line, col;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
line = ls->line_number, col = ls->column;
|
|
|
|
check_next(ls, '{');
|
|
|
|
while (ls->t.token != '}')
|
|
|
|
parse_param(ls, params, allow_inout, is_vals);
|
|
|
|
check_match(ls, '}', '{', line, col);
|
|
|
|
}
|
|
|
|
|
2014-09-10 07:53:20 -07:00
|
|
|
static void
|
2014-09-10 08:58:29 -07:00
|
|
|
parse_accessor(Eo_Lexer *ls, Eolian_Function *prop)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-07-02 16:00:02 -07:00
|
|
|
int line, col;
|
2014-08-18 06:51:03 -07:00
|
|
|
Eina_Bool has_return = EINA_FALSE, has_legacy = EINA_FALSE,
|
2015-05-20 09:42:00 -07:00
|
|
|
has_eo = EINA_FALSE, has_keys = EINA_FALSE,
|
2016-06-09 08:54:43 -07:00
|
|
|
has_values = EINA_FALSE, has_protected = EINA_FALSE,
|
2017-01-13 06:40:29 -08:00
|
|
|
has_virtp = EINA_FALSE;
|
2014-09-10 07:53:20 -07:00
|
|
|
Eina_Bool is_get = (ls->t.kw == KW_get);
|
|
|
|
if (is_get)
|
|
|
|
{
|
2014-09-10 08:58:29 -07:00
|
|
|
if (prop->base.file)
|
|
|
|
eina_stringshare_del(prop->base.file);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(prop->base, ls, ls->line_number, ls->column);
|
2014-09-10 08:17:47 -07:00
|
|
|
if (prop->type == EOLIAN_PROP_SET)
|
|
|
|
prop->type = EOLIAN_PROPERTY;
|
|
|
|
else
|
|
|
|
prop->type = EOLIAN_PROP_GET;
|
2014-09-10 07:53:20 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(prop->set_base, ls, ls->line_number, ls->column);
|
2014-09-10 08:17:47 -07:00
|
|
|
if (prop->type == EOLIAN_PROP_GET)
|
|
|
|
prop->type = EOLIAN_PROPERTY;
|
|
|
|
else
|
|
|
|
prop->type = EOLIAN_PROP_SET;
|
2014-09-10 07:53:20 -07:00
|
|
|
}
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2016-06-09 08:54:43 -07:00
|
|
|
for (;;) switch (ls->t.kw)
|
2016-05-12 07:41:56 -07:00
|
|
|
{
|
2017-01-13 06:44:09 -08:00
|
|
|
case KW_at_pure_virtual:
|
|
|
|
CASE_LOCK(ls, virtp, "pure_virtual qualifier");
|
2017-01-16 06:51:11 -08:00
|
|
|
if (is_get) prop->impl->get_pure_virtual = EINA_TRUE;
|
|
|
|
else prop->impl->set_pure_virtual = EINA_TRUE;
|
2016-05-12 07:41:56 -07:00
|
|
|
eo_lexer_get(ls);
|
2016-06-09 08:54:43 -07:00
|
|
|
break;
|
|
|
|
case KW_at_protected:
|
|
|
|
CASE_LOCK(ls, protected, "protected qualifier");
|
|
|
|
if (is_get) prop->get_scope = EOLIAN_SCOPE_PROTECTED;
|
|
|
|
else prop->set_scope = EOLIAN_SCOPE_PROTECTED;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto parse_accessor;
|
2016-05-12 07:41:56 -07:00
|
|
|
}
|
2016-06-09 08:54:43 -07:00
|
|
|
parse_accessor:
|
2014-06-18 03:25:07 -07:00
|
|
|
line = ls->line_number;
|
2014-07-02 16:00:02 -07:00
|
|
|
col = ls->column;
|
2014-06-18 03:25:07 -07:00
|
|
|
check_next(ls, '{');
|
2017-01-19 05:46:40 -08:00
|
|
|
if ((ls->t.token == TOK_DOC) && !prop->impl->common_doc)
|
2016-05-19 08:57:12 -07:00
|
|
|
{
|
|
|
|
if (getenv("EOLIAN_PROPERTY_DOC_WARN"))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "eolian:%s:%d:%d: %s doc without property "
|
|
|
|
"doc for '%s.%s'\n",
|
|
|
|
prop->base.file, line, col, is_get ? "getter" : "setter",
|
|
|
|
ls->tmp.kls->full_name, prop->name);
|
|
|
|
}
|
|
|
|
}
|
2015-06-03 07:35:13 -07:00
|
|
|
if (is_get)
|
|
|
|
{
|
2017-01-19 05:46:40 -08:00
|
|
|
FILL_DOC(ls, prop->impl, get_doc);
|
2015-06-03 07:35:13 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-19 05:46:40 -08:00
|
|
|
FILL_DOC(ls, prop->impl, set_doc);
|
2015-06-03 07:35:13 -07:00
|
|
|
}
|
2014-07-01 10:25:17 -07:00
|
|
|
for (;;) switch (ls->t.kw)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_return:
|
|
|
|
CASE_LOCK(ls, return, "return")
|
2014-09-10 08:17:47 -07:00
|
|
|
Eo_Ret_Def ret;
|
2017-09-15 06:54:48 -07:00
|
|
|
parse_return(ls, &ret, is_get, EINA_TRUE, EINA_FALSE);
|
2014-09-10 08:17:47 -07:00
|
|
|
pop_type(ls);
|
|
|
|
if (ret.default_ret_val) pop_expr(ls);
|
2014-09-10 07:53:20 -07:00
|
|
|
if (is_get)
|
2014-09-10 08:17:47 -07:00
|
|
|
{
|
|
|
|
prop->get_ret_type = ret.type;
|
2015-06-03 07:35:13 -07:00
|
|
|
prop->get_return_doc = ret.doc;
|
2014-09-10 08:17:47 -07:00
|
|
|
prop->get_ret_val = ret.default_ret_val;
|
|
|
|
prop->get_return_warn_unused = ret.warn_unused;
|
2017-09-15 06:51:25 -07:00
|
|
|
prop->get_return_owned = ret.owned;
|
2014-09-10 08:17:47 -07:00
|
|
|
}
|
2014-09-10 07:53:20 -07:00
|
|
|
else
|
2014-09-10 08:17:47 -07:00
|
|
|
{
|
|
|
|
prop->set_ret_type = ret.type;
|
2015-06-03 07:35:13 -07:00
|
|
|
prop->set_return_doc = ret.doc;
|
2014-09-10 08:17:47 -07:00
|
|
|
prop->set_ret_val = ret.default_ret_val;
|
|
|
|
prop->set_return_warn_unused = ret.warn_unused;
|
2017-09-15 06:51:25 -07:00
|
|
|
prop->set_return_owned = ret.owned;
|
2014-09-10 08:17:47 -07:00
|
|
|
}
|
2014-07-01 10:25:17 -07:00
|
|
|
break;
|
|
|
|
case KW_legacy:
|
|
|
|
CASE_LOCK(ls, legacy, "legacy name")
|
2014-09-10 07:53:20 -07:00
|
|
|
if (is_get)
|
2014-09-12 05:30:24 -07:00
|
|
|
parse_legacy(ls, &prop->get_legacy);
|
2014-09-10 07:53:20 -07:00
|
|
|
else
|
2014-09-12 05:30:24 -07:00
|
|
|
parse_legacy(ls, &prop->set_legacy);
|
2014-07-01 10:25:17 -07:00
|
|
|
break;
|
2014-08-18 06:51:03 -07:00
|
|
|
case KW_eo:
|
|
|
|
CASE_LOCK(ls, eo, "eo name")
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ':');
|
|
|
|
check_kw_next(ls, KW_null);
|
|
|
|
check_next(ls, ';');
|
2014-09-10 07:53:20 -07:00
|
|
|
if (is_get)
|
|
|
|
prop->get_only_legacy = EINA_TRUE;
|
|
|
|
else
|
|
|
|
prop->set_only_legacy = EINA_TRUE;
|
2014-08-18 06:51:03 -07:00
|
|
|
break;
|
2015-05-20 09:42:00 -07:00
|
|
|
case KW_keys:
|
|
|
|
{
|
|
|
|
Eina_List **stor;
|
|
|
|
CASE_LOCK(ls, keys, "keys definition")
|
|
|
|
stor = is_get ? &prop->prop_keys_get : &prop->prop_keys_set;
|
|
|
|
parse_params(ls, stor, EINA_FALSE, EINA_FALSE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case KW_values:
|
|
|
|
{
|
|
|
|
Eina_List **stor;
|
|
|
|
CASE_LOCK(ls, values, "values definition")
|
|
|
|
stor = is_get ? &prop->prop_values_get : &prop->prop_values_set;
|
|
|
|
parse_params(ls, stor, EINA_FALSE, EINA_TRUE);
|
|
|
|
break;
|
|
|
|
}
|
2014-07-01 10:25:17 -07:00
|
|
|
default:
|
2014-09-10 07:06:12 -07:00
|
|
|
goto end;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
end:
|
2014-07-02 16:00:02 -07:00
|
|
|
check_match(ls, '}', '{', line, col);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
2014-09-10 08:58:29 -07:00
|
|
|
static void
|
2017-01-13 06:40:29 -08:00
|
|
|
_func_pure_virtual_set(Eo_Lexer *ls, Eolian_Function *foo_id, Eina_Bool virt)
|
2014-09-10 08:58:29 -07:00
|
|
|
{
|
2016-05-12 07:41:56 -07:00
|
|
|
if (ls->tmp.kls->type != EOLIAN_CLASS_INTERFACE && !virt)
|
2014-09-10 08:58:29 -07:00
|
|
|
return;
|
|
|
|
|
2014-09-11 02:29:48 -07:00
|
|
|
if (foo_id->type == EOLIAN_PROP_GET || foo_id->type == EOLIAN_METHOD)
|
2017-01-16 06:51:11 -08:00
|
|
|
foo_id->impl->get_pure_virtual = EINA_TRUE;
|
2014-09-10 08:58:29 -07:00
|
|
|
else if (foo_id->type == EOLIAN_PROP_SET)
|
2017-01-16 06:51:11 -08:00
|
|
|
foo_id->impl->set_pure_virtual = EINA_TRUE;
|
2014-09-11 02:29:48 -07:00
|
|
|
else if (foo_id->type == EOLIAN_PROPERTY)
|
2017-01-16 06:51:11 -08:00
|
|
|
foo_id->impl->get_pure_virtual = foo_id->impl->set_pure_virtual = EINA_TRUE;
|
2014-09-10 08:58:29 -07:00
|
|
|
}
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
static void
|
|
|
|
parse_property(Eo_Lexer *ls)
|
|
|
|
{
|
2014-07-02 16:00:02 -07:00
|
|
|
int line, col;
|
2014-09-10 08:58:29 -07:00
|
|
|
Eolian_Function *prop = NULL;
|
2017-01-16 06:51:11 -08:00
|
|
|
Eolian_Implement *impl = NULL;
|
2014-07-24 04:05:12 -07:00
|
|
|
Eina_Bool has_get = EINA_FALSE, has_set = EINA_FALSE,
|
|
|
|
has_keys = EINA_FALSE, has_values = EINA_FALSE,
|
2014-12-03 06:59:24 -08:00
|
|
|
has_protected = EINA_FALSE, has_class = EINA_FALSE,
|
2017-08-30 10:31:23 -07:00
|
|
|
has_beta = EINA_FALSE, has_virtp = EINA_FALSE;
|
2014-09-10 08:58:29 -07:00
|
|
|
prop = calloc(1, sizeof(Eolian_Function));
|
2014-09-25 07:37:18 -07:00
|
|
|
prop->klass = ls->tmp.kls;
|
2014-09-16 07:10:22 -07:00
|
|
|
prop->type = EOLIAN_UNRESOLVED;
|
2017-01-13 06:15:10 -08:00
|
|
|
prop->get_scope = prop->set_scope = EOLIAN_SCOPE_PUBLIC;
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(prop->base, ls, ls->line_number, ls->column);
|
2017-01-16 06:51:11 -08:00
|
|
|
impl = calloc(1, sizeof(Eolian_Implement));
|
|
|
|
impl->klass = ls->tmp.kls;
|
|
|
|
impl->foo_id = prop;
|
|
|
|
FILL_BASE(impl->base, ls, ls->line_number, ls->column);
|
|
|
|
prop->impl = impl;
|
2014-09-12 05:25:26 -07:00
|
|
|
ls->tmp.kls->properties = eina_list_append(ls->tmp.kls->properties, prop);
|
2017-01-16 06:51:11 -08:00
|
|
|
ls->tmp.kls->implements = eina_list_append(ls->tmp.kls->implements, impl);
|
2014-07-22 08:35:54 -07:00
|
|
|
check(ls, TOK_VALUE);
|
2016-08-23 05:43:46 -07:00
|
|
|
if (ls->t.kw == KW_get || ls->t.kw == KW_set)
|
|
|
|
{
|
|
|
|
eo_lexer_syntax_error(ls, "reserved keyword as property name");
|
|
|
|
return;
|
|
|
|
}
|
2014-07-17 09:16:31 -07:00
|
|
|
prop->name = eina_stringshare_ref(ls->t.value.s);
|
2017-01-16 06:51:11 -08:00
|
|
|
impl->full_name = eina_stringshare_printf("%s.%s", ls->tmp.kls->full_name, prop->name);
|
2014-07-22 08:35:54 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-07-24 04:05:12 -07:00
|
|
|
for (;;) switch (ls->t.kw)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-07-24 04:05:12 -07:00
|
|
|
case KW_at_protected:
|
|
|
|
CASE_LOCK(ls, protected, "protected qualifier")
|
2016-06-09 08:54:43 -07:00
|
|
|
prop->get_scope = prop->set_scope = EOLIAN_SCOPE_PROTECTED;
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-07-24 04:05:12 -07:00
|
|
|
break;
|
|
|
|
case KW_at_class:
|
|
|
|
CASE_LOCK(ls, class, "class qualifier");
|
|
|
|
prop->is_class = EINA_TRUE;
|
2014-07-24 06:01:33 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2015-05-08 06:00:07 -07:00
|
|
|
case KW_at_beta:
|
|
|
|
CASE_LOCK(ls, beta, "beta qualifier");
|
|
|
|
prop->is_beta = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2017-01-13 06:44:09 -08:00
|
|
|
case KW_at_pure_virtual:
|
|
|
|
CASE_LOCK(ls, virtp, "pure_virtual qualifier");
|
2016-05-12 07:41:56 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2014-07-24 04:05:12 -07:00
|
|
|
default:
|
|
|
|
goto body;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
2014-07-24 04:05:12 -07:00
|
|
|
body:
|
2014-06-18 03:25:07 -07:00
|
|
|
line = ls->line_number;
|
2014-07-02 16:00:02 -07:00
|
|
|
col = ls->column;
|
2014-06-18 03:25:07 -07:00
|
|
|
check_next(ls, '{');
|
2017-01-19 05:46:40 -08:00
|
|
|
FILL_DOC(ls, prop->impl, common_doc);
|
2014-07-01 10:25:17 -07:00
|
|
|
for (;;) switch (ls->t.kw)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_get:
|
|
|
|
CASE_LOCK(ls, get, "get definition")
|
2017-01-16 06:51:11 -08:00
|
|
|
impl->is_prop_get = EINA_TRUE;
|
2014-09-10 07:53:20 -07:00
|
|
|
parse_accessor(ls, prop);
|
2014-07-01 10:25:17 -07:00
|
|
|
break;
|
|
|
|
case KW_set:
|
|
|
|
CASE_LOCK(ls, set, "set definition")
|
2017-01-16 06:51:11 -08:00
|
|
|
impl->is_prop_set = EINA_TRUE;
|
2014-09-10 07:53:20 -07:00
|
|
|
parse_accessor(ls, prop);
|
2014-07-01 10:25:17 -07:00
|
|
|
break;
|
|
|
|
case KW_keys:
|
|
|
|
CASE_LOCK(ls, keys, "keys definition")
|
2015-05-20 09:42:00 -07:00
|
|
|
parse_params(ls, &prop->prop_keys, EINA_FALSE, EINA_FALSE);
|
2014-07-01 10:25:17 -07:00
|
|
|
break;
|
|
|
|
case KW_values:
|
|
|
|
CASE_LOCK(ls, values, "values definition")
|
2015-05-20 09:42:00 -07:00
|
|
|
parse_params(ls, &prop->prop_values, EINA_FALSE, EINA_TRUE);
|
2014-07-01 10:25:17 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto end;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
end:
|
2014-07-02 16:00:02 -07:00
|
|
|
check_match(ls, '}', '{', line, col);
|
2014-09-10 08:46:34 -07:00
|
|
|
if (!has_get && !has_set)
|
2017-01-16 06:51:11 -08:00
|
|
|
{
|
|
|
|
prop->type = EOLIAN_PROPERTY;
|
|
|
|
impl->is_prop_get = impl->is_prop_set = EINA_TRUE;
|
|
|
|
}
|
2017-01-13 06:40:29 -08:00
|
|
|
_func_pure_virtual_set(ls, prop, has_virtp);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
2017-04-07 09:54:55 -07:00
|
|
|
static Eolian_Typedecl*
|
|
|
|
parse_function_pointer(Eo_Lexer *ls)
|
|
|
|
{
|
2017-08-30 07:02:30 -07:00
|
|
|
int bline, bcol;
|
|
|
|
int line = ls->line_number, col = ls->column;
|
|
|
|
|
2017-04-07 09:54:55 -07:00
|
|
|
Eolian_Typedecl *def = push_typedecl(ls);
|
|
|
|
Eina_Strbuf *buf = push_strbuf(ls);
|
|
|
|
Eolian_Function *meth = NULL;
|
|
|
|
|
2017-08-30 04:53:22 -07:00
|
|
|
Eina_Bool has_params = EINA_FALSE,
|
2017-08-30 10:31:23 -07:00
|
|
|
has_return = EINA_FALSE;
|
2017-04-07 09:54:55 -07:00
|
|
|
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
|
|
|
|
def->type = EOLIAN_TYPEDECL_FUNCTION_POINTER;
|
2017-08-30 07:02:30 -07:00
|
|
|
def->is_extern = (ls->t.kw == KW_at_extern);
|
|
|
|
if (def->is_extern)
|
|
|
|
eo_lexer_get(ls);
|
2017-04-07 09:54:55 -07:00
|
|
|
|
2017-08-30 07:02:30 -07:00
|
|
|
parse_name(ls, buf);
|
2017-04-07 09:54:55 -07:00
|
|
|
_fill_name(eina_stringshare_add(eina_strbuf_string_get(buf)),
|
|
|
|
&def->full_name, &def->name, &def->namespaces);
|
|
|
|
|
|
|
|
pop_strbuf(ls);
|
|
|
|
|
|
|
|
meth = calloc(1, sizeof(Eolian_Function));
|
|
|
|
meth->klass = NULL;
|
|
|
|
meth->type = EOLIAN_FUNCTION_POINTER;
|
|
|
|
meth->get_scope = meth->set_scope = EOLIAN_SCOPE_PUBLIC;
|
|
|
|
meth->name = eina_stringshare_ref(def->name);
|
|
|
|
|
|
|
|
def->function_pointer = meth;
|
|
|
|
|
2017-08-30 10:31:23 -07:00
|
|
|
meth->is_beta = (ls->t.kw == KW_at_beta);
|
|
|
|
if (meth->is_beta)
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
|
2017-08-30 07:02:30 -07:00
|
|
|
bline = ls->line_number;
|
|
|
|
bcol = ls->column;
|
2017-04-07 09:54:55 -07:00
|
|
|
check_next(ls, '{');
|
2017-08-28 08:27:47 -07:00
|
|
|
FILL_DOC(ls, def, doc);
|
2017-04-07 09:54:55 -07:00
|
|
|
for (;;) switch (ls->t.kw)
|
|
|
|
{
|
|
|
|
case KW_return:
|
|
|
|
CASE_LOCK(ls, return, "return");
|
|
|
|
Eo_Ret_Def ret;
|
2017-09-15 06:54:48 -07:00
|
|
|
parse_return(ls, &ret, EINA_FALSE, EINA_FALSE, EINA_TRUE);
|
2017-04-07 09:54:55 -07:00
|
|
|
pop_type(ls);
|
|
|
|
meth->get_ret_type = ret.type;
|
|
|
|
meth->get_return_doc = ret.doc;
|
|
|
|
meth->get_ret_val = NULL;
|
|
|
|
meth->get_return_warn_unused = EINA_FALSE;
|
2017-09-15 06:51:25 -07:00
|
|
|
meth->get_return_owned = EINA_FALSE;
|
2017-04-07 09:54:55 -07:00
|
|
|
break;
|
|
|
|
case KW_params:
|
|
|
|
CASE_LOCK(ls, params, "params definition");
|
|
|
|
parse_params(ls, &meth->params, EINA_TRUE, EINA_FALSE);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
end:
|
2017-08-30 07:02:30 -07:00
|
|
|
check_match(ls, '}', '{', bline, bcol);
|
2017-04-07 09:54:55 -07:00
|
|
|
check_next(ls, ';');
|
2017-08-30 07:02:30 -07:00
|
|
|
FILL_BASE(def->base, ls, line, col);
|
|
|
|
FILL_BASE(meth->base, ls, line, col);
|
2017-04-07 09:54:55 -07:00
|
|
|
return def;
|
|
|
|
}
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
static void
|
2014-12-03 06:59:24 -08:00
|
|
|
parse_method(Eo_Lexer *ls)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-07-02 16:00:02 -07:00
|
|
|
int line, col;
|
2014-09-11 02:29:48 -07:00
|
|
|
Eolian_Function *meth = NULL;
|
2017-01-16 06:51:11 -08:00
|
|
|
Eolian_Implement *impl = NULL;
|
2014-06-18 03:25:07 -07:00
|
|
|
Eina_Bool has_const = EINA_FALSE, has_params = EINA_FALSE,
|
2014-07-22 09:13:24 -07:00
|
|
|
has_return = EINA_FALSE, has_legacy = EINA_FALSE,
|
2014-07-24 05:01:47 -07:00
|
|
|
has_protected = EINA_FALSE, has_class = EINA_FALSE,
|
2017-08-30 10:31:23 -07:00
|
|
|
has_eo = EINA_FALSE, has_beta = EINA_FALSE,
|
|
|
|
has_virtp = EINA_FALSE;
|
2014-09-11 02:29:48 -07:00
|
|
|
meth = calloc(1, sizeof(Eolian_Function));
|
2014-09-25 07:37:18 -07:00
|
|
|
meth->klass = ls->tmp.kls;
|
2014-09-11 02:29:48 -07:00
|
|
|
meth->type = EOLIAN_METHOD;
|
2017-01-13 06:15:10 -08:00
|
|
|
meth->get_scope = meth->set_scope = EOLIAN_SCOPE_PUBLIC;
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(meth->base, ls, ls->line_number, ls->column);
|
2017-01-16 06:51:11 -08:00
|
|
|
impl = calloc(1, sizeof(Eolian_Implement));
|
|
|
|
impl->klass = ls->tmp.kls;
|
|
|
|
impl->foo_id = meth;
|
|
|
|
FILL_BASE(impl->base, ls, ls->line_number, ls->column);
|
|
|
|
meth->impl = impl;
|
2014-09-12 05:25:26 -07:00
|
|
|
ls->tmp.kls->methods = eina_list_append(ls->tmp.kls->methods, meth);
|
2017-01-16 06:51:11 -08:00
|
|
|
ls->tmp.kls->implements = eina_list_append(ls->tmp.kls->implements, impl);
|
2014-12-03 06:59:24 -08:00
|
|
|
check(ls, TOK_VALUE);
|
2016-08-23 05:43:46 -07:00
|
|
|
if (ls->t.kw == KW_get || ls->t.kw == KW_set)
|
|
|
|
{
|
|
|
|
eo_lexer_syntax_error(ls, "reserved keyword as method name");
|
|
|
|
return;
|
|
|
|
}
|
2014-12-03 06:59:24 -08:00
|
|
|
meth->name = eina_stringshare_ref(ls->t.value.s);
|
2017-01-16 06:51:11 -08:00
|
|
|
impl->full_name = eina_stringshare_printf("%s.%s", ls->tmp.kls->full_name, meth->name);
|
2014-12-03 06:59:24 -08:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
for (;;) switch (ls->t.kw)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-12-03 06:59:24 -08:00
|
|
|
case KW_at_protected:
|
|
|
|
CASE_LOCK(ls, protected, "protected qualifier")
|
2016-06-09 08:54:43 -07:00
|
|
|
meth->get_scope = meth->set_scope = EOLIAN_SCOPE_PROTECTED;
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-12-03 06:59:24 -08:00
|
|
|
break;
|
|
|
|
case KW_at_const:
|
|
|
|
CASE_LOCK(ls, const, "const qualifier")
|
|
|
|
meth->obj_is_const = EINA_TRUE;
|
2014-07-22 08:35:54 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-12-03 06:59:24 -08:00
|
|
|
break;
|
|
|
|
case KW_at_class:
|
|
|
|
CASE_LOCK(ls, class, "class qualifier");
|
|
|
|
meth->is_class = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2015-05-08 06:00:07 -07:00
|
|
|
case KW_at_beta:
|
|
|
|
CASE_LOCK(ls, beta, "beta qualifier");
|
|
|
|
meth->is_beta = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2017-01-13 06:44:09 -08:00
|
|
|
case KW_at_pure_virtual:
|
|
|
|
CASE_LOCK(ls, virtp, "pure_virtual qualifier");
|
2016-05-12 07:41:56 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2014-12-03 06:59:24 -08:00
|
|
|
default:
|
|
|
|
goto body;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
2014-07-22 09:13:24 -07:00
|
|
|
body:
|
2014-06-18 03:25:07 -07:00
|
|
|
line = ls->line_number;
|
2014-07-02 16:00:02 -07:00
|
|
|
col = ls->column;
|
2014-06-18 03:25:07 -07:00
|
|
|
check_next(ls, '{');
|
2017-01-19 05:46:40 -08:00
|
|
|
FILL_DOC(ls, meth->impl, common_doc);
|
2014-07-01 10:25:17 -07:00
|
|
|
for (;;) switch (ls->t.kw)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_return:
|
|
|
|
CASE_LOCK(ls, return, "return")
|
2014-09-10 08:17:47 -07:00
|
|
|
Eo_Ret_Def ret;
|
2017-09-15 06:54:48 -07:00
|
|
|
parse_return(ls, &ret, EINA_FALSE, EINA_TRUE, EINA_FALSE);
|
2014-09-10 08:17:47 -07:00
|
|
|
pop_type(ls);
|
|
|
|
if (ret.default_ret_val) pop_expr(ls);
|
2014-09-11 02:29:48 -07:00
|
|
|
meth->get_ret_type = ret.type;
|
2015-06-03 07:35:13 -07:00
|
|
|
meth->get_return_doc = ret.doc;
|
2014-09-11 02:29:48 -07:00
|
|
|
meth->get_ret_val = ret.default_ret_val;
|
|
|
|
meth->get_return_warn_unused = ret.warn_unused;
|
2017-09-15 06:51:25 -07:00
|
|
|
meth->get_return_owned = ret.owned;
|
2014-07-01 10:25:17 -07:00
|
|
|
break;
|
|
|
|
case KW_legacy:
|
|
|
|
CASE_LOCK(ls, legacy, "legacy name")
|
2014-09-12 05:30:24 -07:00
|
|
|
parse_legacy(ls, &meth->get_legacy);
|
2014-07-01 10:25:17 -07:00
|
|
|
break;
|
2014-08-18 06:51:03 -07:00
|
|
|
case KW_eo:
|
|
|
|
CASE_LOCK(ls, eo, "eo name")
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ':');
|
|
|
|
check_kw_next(ls, KW_null);
|
|
|
|
check_next(ls, ';');
|
2014-09-11 02:29:48 -07:00
|
|
|
meth->get_only_legacy = EINA_TRUE;
|
2014-08-18 06:51:03 -07:00
|
|
|
break;
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_params:
|
|
|
|
CASE_LOCK(ls, params, "params definition")
|
2014-09-12 05:35:48 -07:00
|
|
|
parse_params(ls, &meth->params, EINA_TRUE, EINA_FALSE);
|
2014-07-01 10:25:17 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto end;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
end:
|
2014-07-02 16:00:02 -07:00
|
|
|
check_match(ls, '}', '{', line, col);
|
2017-01-13 06:40:29 -08:00
|
|
|
_func_pure_virtual_set(ls, meth, has_virtp);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-20 04:24:10 -07:00
|
|
|
parse_implement(Eo_Lexer *ls, Eina_Bool iface)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
|
|
|
Eina_Strbuf *buf = NULL;
|
2014-07-10 07:23:06 -07:00
|
|
|
Eolian_Implement *impl = NULL;
|
2014-09-11 03:18:48 -07:00
|
|
|
int iline = ls->line_number, icol = ls->column;
|
2014-06-20 04:24:10 -07:00
|
|
|
if (iface)
|
2014-07-01 10:25:17 -07:00
|
|
|
check_kw(ls, KW_class);
|
2014-06-18 03:25:07 -07:00
|
|
|
if (ls->t.kw == KW_class)
|
|
|
|
{
|
|
|
|
eo_lexer_get(ls);
|
2014-06-20 02:45:55 -07:00
|
|
|
check_next(ls, '.');
|
2014-06-18 03:25:07 -07:00
|
|
|
if (ls->t.kw == KW_destructor)
|
|
|
|
{
|
2014-09-11 03:18:48 -07:00
|
|
|
ls->tmp.kls->class_dtor_enable = EINA_TRUE;
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
check_kw_next(ls, KW_constructor);
|
2014-09-11 03:18:48 -07:00
|
|
|
ls->tmp.kls->class_ctor_enable = EINA_TRUE;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
check_next(ls, ';');
|
|
|
|
return;
|
|
|
|
}
|
2017-01-11 10:25:54 -08:00
|
|
|
Eina_Bool glob_auto = EINA_FALSE, glob_empty = EINA_FALSE;
|
2014-08-29 06:33:56 -07:00
|
|
|
switch (ls->t.kw)
|
|
|
|
{
|
|
|
|
case KW_at_auto:
|
2017-01-11 10:25:54 -08:00
|
|
|
glob_auto = EINA_TRUE;
|
2014-08-29 06:33:56 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
|
|
|
case KW_at_empty:
|
2017-01-11 10:25:54 -08:00
|
|
|
glob_empty = EINA_TRUE;
|
2014-08-29 06:33:56 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ls->t.token == '.')
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2017-01-11 10:25:54 -08:00
|
|
|
eo_lexer_get(ls);
|
2016-12-27 10:37:15 -08:00
|
|
|
if (ls->t.token != TOK_VALUE)
|
2014-07-01 10:25:17 -07:00
|
|
|
eo_lexer_syntax_error(ls, "name expected");
|
2017-01-16 06:51:11 -08:00
|
|
|
Eina_Stringshare *iname = eina_stringshare_printf("%s.%s",
|
|
|
|
ls->tmp.kls->full_name,
|
|
|
|
ls->t.value.s);
|
|
|
|
Eina_List *l;
|
|
|
|
Eolian_Implement *fimp;
|
|
|
|
EINA_LIST_FOREACH(ls->tmp.kls->implements, l, fimp)
|
|
|
|
if (iname == fimp->full_name)
|
|
|
|
{
|
|
|
|
impl = fimp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
eina_stringshare_del(iname);
|
|
|
|
if (!impl)
|
2017-02-10 07:56:35 -08:00
|
|
|
{
|
|
|
|
eo_lexer_syntax_error(ls, "implement of non-existent function");
|
|
|
|
return;
|
|
|
|
}
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2016-12-27 10:33:12 -08:00
|
|
|
goto propbeg;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
2017-01-16 06:51:11 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
impl = calloc(1, sizeof(Eolian_Implement));
|
|
|
|
FILL_BASE(impl->base, ls, iline, icol);
|
|
|
|
ls->tmp.kls->implements = eina_list_append(ls->tmp.kls->implements, impl);
|
|
|
|
}
|
2016-12-27 10:37:15 -08:00
|
|
|
if (ls->t.token != TOK_VALUE)
|
2014-07-01 10:25:17 -07:00
|
|
|
eo_lexer_syntax_error(ls, "class name expected");
|
2014-08-29 03:40:29 -07:00
|
|
|
buf = push_strbuf(ls);
|
2014-07-17 09:16:31 -07:00
|
|
|
eina_strbuf_append(buf, ls->t.value.s);
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-06-20 02:45:55 -07:00
|
|
|
check_next(ls, '.');
|
2016-12-27 10:37:15 -08:00
|
|
|
if (ls->t.token != TOK_VALUE)
|
2014-07-01 10:25:17 -07:00
|
|
|
eo_lexer_syntax_error(ls, "name or constructor/destructor expected");
|
2014-06-18 03:25:07 -07:00
|
|
|
for (;;)
|
|
|
|
{
|
2016-12-27 10:37:15 -08:00
|
|
|
if ((ls->t.kw == KW_constructor) || (ls->t.kw == KW_destructor))
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-08-29 07:06:48 -07:00
|
|
|
eina_strbuf_append_char(buf, '.');
|
|
|
|
eina_strbuf_append(buf, eo_lexer_keyword_str_get(ls->t.kw));
|
|
|
|
eo_lexer_get(ls);
|
2017-01-18 06:33:44 -08:00
|
|
|
check(ls, ';');
|
|
|
|
goto propbeg;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
2014-08-29 07:06:48 -07:00
|
|
|
eina_strbuf_append_char(buf, '.');
|
2014-06-18 03:25:07 -07:00
|
|
|
check(ls, TOK_VALUE);
|
2014-07-17 09:16:31 -07:00
|
|
|
eina_strbuf_append(buf, ls->t.value.s);
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-06-20 02:45:55 -07:00
|
|
|
if (ls->t.token != '.') break;
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
2016-12-27 10:33:12 -08:00
|
|
|
propbeg:
|
2016-12-23 08:24:00 -08:00
|
|
|
if (ls->t.token == '{')
|
|
|
|
{
|
|
|
|
Eina_Bool has_get = EINA_FALSE, has_set = EINA_FALSE;
|
|
|
|
eo_lexer_get(ls);
|
2017-01-18 06:33:44 -08:00
|
|
|
FILL_DOC(ls, impl, common_doc);
|
2016-12-23 08:24:00 -08:00
|
|
|
for (;;) switch (ls->t.kw)
|
|
|
|
{
|
|
|
|
case KW_get:
|
|
|
|
CASE_LOCK(ls, get, "get specifier");
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
impl->is_prop_get = EINA_TRUE;
|
2017-01-11 10:25:54 -08:00
|
|
|
impl->get_auto = glob_auto;
|
|
|
|
impl->get_empty = glob_empty;
|
|
|
|
if (ls->t.kw == KW_at_auto)
|
|
|
|
{
|
|
|
|
impl->get_auto = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
|
|
|
else if (ls->t.kw == KW_at_empty)
|
|
|
|
{
|
|
|
|
impl->get_empty = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
2016-12-27 07:05:22 -08:00
|
|
|
check_next(ls, ';');
|
2017-01-18 06:33:44 -08:00
|
|
|
FILL_DOC(ls, impl, get_doc);
|
2016-12-23 08:24:00 -08:00
|
|
|
break;
|
|
|
|
case KW_set:
|
|
|
|
CASE_LOCK(ls, set, "set specifier");
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
impl->is_prop_set = EINA_TRUE;
|
2017-01-11 10:25:54 -08:00
|
|
|
impl->set_auto = glob_auto;
|
|
|
|
impl->set_empty = glob_empty;
|
|
|
|
if (ls->t.kw == KW_at_auto)
|
|
|
|
{
|
|
|
|
impl->set_auto = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
|
|
|
else if (ls->t.kw == KW_at_empty)
|
|
|
|
{
|
|
|
|
impl->set_empty = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
2016-12-27 07:05:22 -08:00
|
|
|
check_next(ls, ';');
|
2017-01-18 06:33:44 -08:00
|
|
|
FILL_DOC(ls, impl, set_doc);
|
2016-12-23 08:24:00 -08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto propend;
|
|
|
|
}
|
|
|
|
propend:
|
2017-01-02 05:02:44 -08:00
|
|
|
if (!has_get && !has_set)
|
|
|
|
eo_lexer_syntax_error(ls, "property implements need at least get or set specified");
|
2016-12-23 08:24:00 -08:00
|
|
|
check_next(ls, '}');
|
|
|
|
}
|
|
|
|
else
|
2017-01-18 06:33:44 -08:00
|
|
|
{
|
2017-04-19 04:24:38 -07:00
|
|
|
if (glob_auto)
|
|
|
|
impl->get_auto = impl->set_auto = EINA_TRUE;
|
|
|
|
if (glob_empty)
|
|
|
|
impl->get_empty = impl->set_empty = EINA_TRUE;
|
2017-01-18 06:33:44 -08:00
|
|
|
check_next(ls, ';');
|
|
|
|
FILL_DOC(ls, impl, common_doc);
|
|
|
|
}
|
2016-12-27 10:33:12 -08:00
|
|
|
if (buf)
|
|
|
|
{
|
|
|
|
impl->full_name = eina_stringshare_add(eina_strbuf_string_get(buf));
|
|
|
|
pop_strbuf(ls);
|
|
|
|
}
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
2014-09-01 07:35:50 -07:00
|
|
|
static void
|
|
|
|
parse_constructor(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
Eina_Strbuf *buf = NULL;
|
|
|
|
Eolian_Constructor *ctor = NULL;
|
2014-09-03 01:27:09 -07:00
|
|
|
ctor = calloc(1, sizeof(Eolian_Constructor));
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(ctor->base, ls, ls->line_number, ls->column);
|
2014-09-12 05:25:26 -07:00
|
|
|
ls->tmp.kls->constructors = eina_list_append(ls->tmp.kls->constructors, ctor);
|
2014-09-01 07:35:50 -07:00
|
|
|
if (ls->t.token == '.')
|
|
|
|
{
|
|
|
|
check_next(ls, '.');
|
|
|
|
if (ls->t.token != TOK_VALUE)
|
|
|
|
eo_lexer_syntax_error(ls, "name expected");
|
2014-09-11 03:18:48 -07:00
|
|
|
ctor->full_name = eina_stringshare_printf("%s.%s",
|
|
|
|
ls->tmp.kls->full_name,
|
|
|
|
ls->t.value.s);
|
2014-09-01 07:35:50 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-11-20 07:21:44 -08:00
|
|
|
if (ls->t.kw == KW_at_optional)
|
|
|
|
{
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
ctor->is_optional = EINA_TRUE;
|
|
|
|
}
|
2014-09-01 07:35:50 -07:00
|
|
|
check_next(ls, ';');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
check(ls, TOK_VALUE);
|
|
|
|
buf = push_strbuf(ls);
|
|
|
|
eina_strbuf_append(buf, ls->t.value.s);
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, '.');
|
|
|
|
check(ls, TOK_VALUE);
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
eina_strbuf_append_char(buf, '.');
|
|
|
|
check(ls, TOK_VALUE);
|
|
|
|
eina_strbuf_append(buf, ls->t.value.s);
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
if (ls->t.token != '.') break;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
2014-11-20 07:21:44 -08:00
|
|
|
if (ls->t.kw == KW_at_optional)
|
|
|
|
{
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
ctor->is_optional = EINA_TRUE;
|
|
|
|
}
|
2014-09-01 07:35:50 -07:00
|
|
|
check_next(ls, ';');
|
|
|
|
ctor->full_name = eina_stringshare_add(eina_strbuf_string_get(buf));
|
|
|
|
pop_strbuf(ls);
|
|
|
|
}
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
static void
|
|
|
|
parse_event(Eo_Lexer *ls)
|
|
|
|
{
|
2014-07-10 07:31:01 -07:00
|
|
|
Eolian_Event *ev = calloc(1, sizeof(Eolian_Event));
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(ev->base, ls, ls->line_number, ls->column);
|
2017-01-13 06:15:10 -08:00
|
|
|
ev->scope = EOLIAN_SCOPE_PUBLIC;
|
2014-07-16 06:43:40 -07:00
|
|
|
Eina_Strbuf *buf = push_strbuf(ls);
|
2014-09-12 05:25:26 -07:00
|
|
|
ls->tmp.kls->events = eina_list_append(ls->tmp.kls->events, ev);
|
2014-06-18 03:25:07 -07:00
|
|
|
check(ls, TOK_VALUE);
|
2014-07-17 09:16:31 -07:00
|
|
|
eina_strbuf_append(buf, ls->t.value.s);
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-07-16 06:43:40 -07:00
|
|
|
while (ls->t.token == ',')
|
|
|
|
{
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check(ls, TOK_VALUE);
|
|
|
|
eina_strbuf_append_char(buf, ',');
|
2014-07-17 09:16:31 -07:00
|
|
|
eina_strbuf_append(buf, ls->t.value.s);
|
2014-07-16 06:43:40 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
}
|
|
|
|
ev->name = eina_stringshare_add(eina_strbuf_string_get(buf));
|
|
|
|
pop_strbuf(ls);
|
2016-02-02 09:55:01 -08:00
|
|
|
Eina_Bool has_scope = EINA_FALSE, has_beta = EINA_FALSE,
|
2017-09-15 06:51:25 -07:00
|
|
|
has_hot = EINA_FALSE, has_restart = EINA_FALSE,
|
|
|
|
has_owned = EINA_FALSE;
|
2016-02-02 09:55:01 -08:00
|
|
|
for (;;) switch (ls->t.kw)
|
2014-08-13 03:53:33 -07:00
|
|
|
{
|
2016-02-02 09:55:01 -08:00
|
|
|
case KW_at_private:
|
|
|
|
case KW_at_protected:
|
|
|
|
CASE_LOCK(ls, scope, "scope qualifier")
|
|
|
|
ev->scope = (ls->t.kw == KW_at_private)
|
|
|
|
? EOLIAN_SCOPE_PRIVATE
|
|
|
|
: EOLIAN_SCOPE_PROTECTED;
|
2014-08-13 03:53:33 -07:00
|
|
|
eo_lexer_get(ls);
|
2016-02-02 09:55:01 -08:00
|
|
|
break;
|
|
|
|
case KW_at_beta:
|
|
|
|
CASE_LOCK(ls, beta, "beta qualifier")
|
2015-05-08 06:22:32 -07:00
|
|
|
ev->is_beta = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
2016-02-02 09:55:01 -08:00
|
|
|
break;
|
|
|
|
case KW_at_hot:
|
|
|
|
CASE_LOCK(ls, hot, "hot qualifier");
|
|
|
|
ev->is_hot = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2016-04-20 15:53:16 -07:00
|
|
|
case KW_at_restart:
|
|
|
|
CASE_LOCK(ls, restart, "restart qualifier");
|
|
|
|
ev->is_restart = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2017-09-15 06:51:25 -07:00
|
|
|
case KW_at_owned:
|
|
|
|
CASE_LOCK(ls, owned, "owned qualifier");
|
|
|
|
ev->owned = EINA_TRUE;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
break;
|
2016-02-02 09:55:01 -08:00
|
|
|
default:
|
|
|
|
goto end;
|
2015-05-08 06:22:32 -07:00
|
|
|
}
|
2016-02-02 09:55:01 -08:00
|
|
|
end:
|
2014-07-15 15:50:34 -07:00
|
|
|
if (ls->t.token == ':')
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
|
|
|
eo_lexer_get(ls);
|
2016-06-30 06:04:03 -07:00
|
|
|
ev->type = parse_type(ls, EINA_TRUE, EINA_FALSE);
|
2014-07-11 03:47:37 -07:00
|
|
|
pop_type(ls);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
check(ls, ';');
|
2014-07-16 06:43:40 -07:00
|
|
|
eo_lexer_get(ls);
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, ev, doc);
|
2014-09-25 06:58:53 -07:00
|
|
|
ev->klass = ls->tmp.kls;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
parse_methods(Eo_Lexer *ls)
|
|
|
|
{
|
2014-11-21 05:59:42 -08:00
|
|
|
int line, col;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
line = ls->line_number, col = ls->column;
|
|
|
|
check_next(ls, '{');
|
|
|
|
while (ls->t.token != '}')
|
2015-05-07 06:57:46 -07:00
|
|
|
{
|
|
|
|
if (ls->t.kw == KW_at_property)
|
|
|
|
{
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
parse_property(ls);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
parse_method(ls);
|
|
|
|
}
|
2014-07-02 16:00:02 -07:00
|
|
|
check_match(ls, '}', '{', line, col);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-20 04:24:10 -07:00
|
|
|
parse_implements(Eo_Lexer *ls, Eina_Bool iface)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-11-21 05:59:42 -08:00
|
|
|
int line, col;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
line = ls->line_number, col = ls->column;
|
|
|
|
check_next(ls, '{');
|
|
|
|
while (ls->t.token != '}')
|
|
|
|
parse_implement(ls, iface);
|
2014-07-02 16:00:02 -07:00
|
|
|
check_match(ls, '}', '{', line, col);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
2014-09-01 07:35:50 -07:00
|
|
|
static void
|
|
|
|
parse_constructors(Eo_Lexer *ls)
|
|
|
|
{
|
2014-11-21 05:59:42 -08:00
|
|
|
int line, col;
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
line = ls->line_number, col = ls->column;
|
|
|
|
check_next(ls, '{');
|
|
|
|
while (ls->t.token != '}')
|
|
|
|
parse_constructor(ls);
|
2014-09-01 07:35:50 -07:00
|
|
|
check_match(ls, '}', '{', line, col);
|
|
|
|
}
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
static void
|
|
|
|
parse_events(Eo_Lexer *ls)
|
|
|
|
{
|
2014-07-02 16:00:02 -07:00
|
|
|
int line, col;
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
line = ls->line_number;
|
2014-07-02 16:00:02 -07:00
|
|
|
col = ls->column;
|
2014-06-18 03:25:07 -07:00
|
|
|
check(ls, '{');
|
2014-07-16 06:43:40 -07:00
|
|
|
eo_lexer_get(ls);
|
2014-06-18 03:25:07 -07:00
|
|
|
while (ls->t.token != '}')
|
2014-09-12 05:25:26 -07:00
|
|
|
parse_event(ls);
|
2014-07-02 16:00:02 -07:00
|
|
|
check_match(ls, '}', '{', line, col);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
2016-03-07 07:01:13 -08:00
|
|
|
static void
|
|
|
|
_validate_pfx(Eo_Lexer *ls)
|
|
|
|
{
|
|
|
|
char ebuf[PATH_MAX];
|
|
|
|
check(ls, TOK_VALUE);
|
|
|
|
const char *str = ls->t.value.s;
|
|
|
|
if ((*str != '_') && ((*str < 'a') || (*str > 'z')))
|
|
|
|
goto error;
|
|
|
|
for (++str; *str; ++str)
|
|
|
|
{
|
|
|
|
if (*str == '_')
|
|
|
|
continue;
|
|
|
|
if ((*str >= 'a') && (*str <= 'z'))
|
|
|
|
continue;
|
|
|
|
if ((*str >= '0') && (*str <= '9'))
|
|
|
|
continue;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
error:
|
|
|
|
snprintf(ebuf, sizeof(ebuf), "invalid prefix '%s'", ls->t.value.s);
|
|
|
|
eo_lexer_syntax_error(ls, ebuf);
|
|
|
|
}
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
static void
|
2014-08-27 07:38:28 -07:00
|
|
|
parse_class_body(Eo_Lexer *ls, Eolian_Class_Type type)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
|
|
|
Eina_Bool has_legacy_prefix = EINA_FALSE,
|
|
|
|
has_eo_prefix = EINA_FALSE,
|
2016-05-17 09:14:47 -07:00
|
|
|
has_event_prefix = EINA_FALSE,
|
2014-06-18 03:25:07 -07:00
|
|
|
has_data = EINA_FALSE,
|
|
|
|
has_methods = EINA_FALSE,
|
|
|
|
has_implements = EINA_FALSE,
|
2014-09-01 07:35:50 -07:00
|
|
|
has_constructors = EINA_FALSE,
|
2014-06-18 03:25:07 -07:00
|
|
|
has_events = EINA_FALSE;
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, ls->tmp.kls, doc);
|
2014-07-18 09:29:25 -07:00
|
|
|
if (type == EOLIAN_CLASS_INTERFACE)
|
|
|
|
{
|
|
|
|
ls->tmp.kls->data_type = eina_stringshare_add("null");
|
|
|
|
}
|
2014-07-01 10:25:17 -07:00
|
|
|
for (;;) switch (ls->t.kw)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_legacy_prefix:
|
|
|
|
CASE_LOCK(ls, legacy_prefix, "legacy prefix definition")
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ':');
|
2016-03-07 07:01:13 -08:00
|
|
|
_validate_pfx(ls);
|
2014-07-17 09:16:31 -07:00
|
|
|
ls->tmp.kls->legacy_prefix = eina_stringshare_ref(ls->t.value.s);
|
2014-07-01 10:25:17 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ';');
|
|
|
|
break;
|
|
|
|
case KW_eo_prefix:
|
|
|
|
CASE_LOCK(ls, eo_prefix, "eo prefix definition")
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ':');
|
2016-03-07 07:01:13 -08:00
|
|
|
_validate_pfx(ls);
|
2014-07-17 09:16:31 -07:00
|
|
|
ls->tmp.kls->eo_prefix = eina_stringshare_ref(ls->t.value.s);
|
2014-07-01 10:25:17 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ';');
|
|
|
|
break;
|
2016-05-17 09:14:47 -07:00
|
|
|
case KW_event_prefix:
|
|
|
|
CASE_LOCK(ls, event_prefix, "event prefix definition")
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ':');
|
|
|
|
_validate_pfx(ls);
|
|
|
|
ls->tmp.kls->ev_prefix = eina_stringshare_ref(ls->t.value.s);
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ';');
|
|
|
|
break;
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_data:
|
2014-07-18 09:29:25 -07:00
|
|
|
if (type == EOLIAN_CLASS_INTERFACE) return;
|
2014-07-01 10:25:17 -07:00
|
|
|
CASE_LOCK(ls, data, "data definition")
|
|
|
|
eo_lexer_get(ls);
|
2014-07-16 07:33:11 -07:00
|
|
|
check_next(ls, ':');
|
|
|
|
check(ls, TOK_VALUE);
|
2014-07-17 09:16:31 -07:00
|
|
|
ls->tmp.kls->data_type = eina_stringshare_ref(ls->t.value.s);
|
2014-07-01 10:25:17 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ';');
|
|
|
|
break;
|
|
|
|
case KW_methods:
|
|
|
|
CASE_LOCK(ls, methods, "methods definition")
|
|
|
|
parse_methods(ls);
|
|
|
|
break;
|
|
|
|
case KW_implements:
|
|
|
|
CASE_LOCK(ls, implements, "implements definition")
|
|
|
|
parse_implements(ls, type == EOLIAN_CLASS_INTERFACE);
|
|
|
|
break;
|
2014-09-01 07:35:50 -07:00
|
|
|
case KW_constructors:
|
|
|
|
if (type == EOLIAN_CLASS_INTERFACE || type == EOLIAN_CLASS_MIXIN)
|
|
|
|
return;
|
|
|
|
CASE_LOCK(ls, constructors, "constructors definition")
|
|
|
|
parse_constructors(ls);
|
|
|
|
break;
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_events:
|
|
|
|
CASE_LOCK(ls, events, "events definition")
|
|
|
|
parse_events(ls);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-20 07:15:53 -07:00
|
|
|
static void
|
2016-06-14 06:09:13 -07:00
|
|
|
_inherit_dep(Eo_Lexer *ls, Eina_Strbuf *buf, Eina_Bool check_inherit,
|
|
|
|
Eolian_Class_Type type)
|
2015-05-20 07:15:53 -07:00
|
|
|
{
|
|
|
|
const char *fname, *iname;
|
|
|
|
char *fnm;
|
|
|
|
eina_strbuf_reset(buf);
|
|
|
|
eo_lexer_context_push(ls);
|
|
|
|
parse_name(ls, buf);
|
|
|
|
iname = eina_strbuf_string_get(buf);
|
|
|
|
fnm = database_class_to_filename(iname);
|
|
|
|
if (compare_class_file(fnm, ls->filename))
|
|
|
|
{
|
|
|
|
char ebuf[PATH_MAX];
|
|
|
|
free(fnm);
|
|
|
|
eo_lexer_context_restore(ls);
|
|
|
|
snprintf(ebuf, sizeof(ebuf), "class '%s' cannot inherit from itself",
|
|
|
|
iname);
|
|
|
|
eo_lexer_syntax_error(ls, ebuf);
|
2015-05-22 03:26:28 -07:00
|
|
|
return; /* unreachable (longjmp above), make static analysis shut up */
|
2015-05-20 07:15:53 -07:00
|
|
|
}
|
|
|
|
fname = eina_hash_find(_filenames, fnm);
|
|
|
|
free(fnm);
|
|
|
|
if (!fname)
|
|
|
|
{
|
|
|
|
char ebuf[PATH_MAX];
|
|
|
|
eo_lexer_context_restore(ls);
|
|
|
|
snprintf(ebuf, sizeof(ebuf), "unknown inherit '%s'", iname);
|
|
|
|
eo_lexer_syntax_error(ls, ebuf);
|
|
|
|
}
|
2015-05-22 07:03:38 -07:00
|
|
|
_parse_dep(ls, fname, iname);
|
2017-05-24 07:36:23 -07:00
|
|
|
/* FIXME: pass unit properly */
|
|
|
|
const Eolian_Class *dep = eolian_class_get_by_name(NULL, iname);
|
2016-08-16 17:41:26 -07:00
|
|
|
if (!dep)
|
|
|
|
{
|
|
|
|
char ebuf[PATH_MAX];
|
|
|
|
eo_lexer_context_restore(ls);
|
|
|
|
snprintf(ebuf, sizeof(ebuf), "unknown inherit '%s'. Incorrect case?", iname);
|
|
|
|
eo_lexer_syntax_error(ls, ebuf);
|
|
|
|
return;
|
|
|
|
}
|
2016-06-14 06:09:13 -07:00
|
|
|
if (check_inherit) switch (type)
|
|
|
|
{
|
|
|
|
case EOLIAN_CLASS_REGULAR:
|
|
|
|
case EOLIAN_CLASS_ABSTRACT:
|
|
|
|
if (dep->type != EOLIAN_CLASS_REGULAR && dep->type != EOLIAN_CLASS_ABSTRACT)
|
|
|
|
{
|
|
|
|
char ebuf[PATH_MAX];
|
|
|
|
eo_lexer_context_restore(ls);
|
|
|
|
snprintf(ebuf, sizeof(ebuf), "regular classes ('%s') cannot inherit from non-regular classes ('%s')",
|
|
|
|
ls->tmp.kls->full_name, iname);
|
|
|
|
eo_lexer_syntax_error(ls, ebuf);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EOLIAN_CLASS_MIXIN:
|
|
|
|
case EOLIAN_CLASS_INTERFACE:
|
|
|
|
if (dep->type != EOLIAN_CLASS_MIXIN && dep->type != EOLIAN_CLASS_INTERFACE)
|
|
|
|
{
|
|
|
|
char ebuf[PATH_MAX];
|
|
|
|
eo_lexer_context_restore(ls);
|
|
|
|
snprintf(ebuf, sizeof(ebuf), "non-regular classes ('%s') cannot inherit from regular classes ('%s')",
|
|
|
|
ls->tmp.kls->full_name, iname);
|
|
|
|
eo_lexer_syntax_error(ls, ebuf);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2015-05-20 07:15:53 -07:00
|
|
|
ls->tmp.kls->inherits = eina_list_append(ls->tmp.kls->inherits,
|
|
|
|
eina_stringshare_add(iname));
|
|
|
|
eo_lexer_context_pop(ls);
|
|
|
|
}
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
static void
|
2014-08-27 07:38:28 -07:00
|
|
|
parse_class(Eo_Lexer *ls, Eolian_Class_Type type)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2015-05-15 07:10:58 -07:00
|
|
|
Eolian_Declaration *decl;
|
2014-07-30 03:57:11 -07:00
|
|
|
const char *bnm;
|
|
|
|
char *fnm;
|
|
|
|
Eina_Bool same;
|
2014-07-02 16:00:02 -07:00
|
|
|
int line, col;
|
2014-06-18 03:25:07 -07:00
|
|
|
Eina_Strbuf *buf = push_strbuf(ls);
|
2014-09-11 02:50:48 -07:00
|
|
|
ls->tmp.kls = calloc(1, sizeof(Eolian_Class));
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(ls->tmp.kls->base, ls, ls->line_number, ls->column);
|
2014-06-18 03:25:07 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
ls->tmp.kls->type = type;
|
2014-07-30 07:51:08 -07:00
|
|
|
eo_lexer_context_push(ls);
|
2014-06-18 03:25:07 -07:00
|
|
|
parse_name(ls, buf);
|
2014-08-08 07:19:52 -07:00
|
|
|
bnm = eina_stringshare_ref(ls->filename);
|
2014-07-30 03:57:11 -07:00
|
|
|
fnm = database_class_to_filename(eina_strbuf_string_get(buf));
|
2014-08-01 05:59:46 -07:00
|
|
|
same = compare_class_file(bnm, fnm);
|
2014-07-30 03:57:11 -07:00
|
|
|
eina_stringshare_del(bnm);
|
|
|
|
free(fnm);
|
|
|
|
if (!same)
|
2014-07-30 07:51:08 -07:00
|
|
|
{
|
|
|
|
eo_lexer_context_restore(ls);
|
|
|
|
eo_lexer_syntax_error(ls, "class and file names differ");
|
|
|
|
}
|
2014-11-21 06:12:40 -08:00
|
|
|
_fill_name(eina_stringshare_add(eina_strbuf_string_get(buf)),
|
|
|
|
&ls->tmp.kls->full_name, &ls->tmp.kls->name,
|
|
|
|
&ls->tmp.kls->namespaces);
|
2015-05-15 07:10:58 -07:00
|
|
|
decl = (Eolian_Declaration *)eina_hash_find(_decls, ls->tmp.kls->full_name);
|
|
|
|
if (decl)
|
|
|
|
{
|
|
|
|
eo_lexer_context_restore(ls);
|
|
|
|
redef_error(ls, decl, EOLIAN_DECL_CLASS);
|
|
|
|
}
|
|
|
|
eo_lexer_context_pop(ls);
|
2014-06-18 03:25:07 -07:00
|
|
|
pop_strbuf(ls);
|
2014-06-19 08:30:18 -07:00
|
|
|
if (ls->t.token != '{')
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-06-19 08:30:18 -07:00
|
|
|
line = ls->line_number;
|
2014-07-02 16:00:02 -07:00
|
|
|
col = ls->column;
|
2014-06-19 08:30:18 -07:00
|
|
|
check_next(ls, '(');
|
|
|
|
if (ls->t.token != ')')
|
2015-05-20 07:15:53 -07:00
|
|
|
{
|
|
|
|
Eina_Strbuf *ibuf = push_strbuf(ls);
|
2016-06-14 06:09:13 -07:00
|
|
|
_inherit_dep(ls, ibuf, EINA_TRUE, type);
|
2015-05-20 07:15:53 -07:00
|
|
|
while (test_next(ls, ','))
|
2016-06-14 06:09:13 -07:00
|
|
|
_inherit_dep(ls, ibuf, EINA_FALSE, type);
|
2015-05-20 07:15:53 -07:00
|
|
|
pop_strbuf(ls);
|
|
|
|
}
|
2014-07-02 16:00:02 -07:00
|
|
|
check_match(ls, ')', '(', line, col);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
line = ls->line_number;
|
2014-07-02 16:00:02 -07:00
|
|
|
col = ls->column;
|
2014-06-18 03:25:07 -07:00
|
|
|
check_next(ls, '{');
|
2014-08-27 07:38:28 -07:00
|
|
|
parse_class_body(ls, type);
|
2014-07-02 16:00:02 -07:00
|
|
|
check_match(ls, '}', '{', line, col);
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
2014-07-30 03:57:11 -07:00
|
|
|
static Eina_Bool
|
2014-06-24 05:45:51 -07:00
|
|
|
parse_unit(Eo_Lexer *ls, Eina_Bool eot)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
|
|
|
switch (ls->t.kw)
|
|
|
|
{
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_abstract:
|
|
|
|
if (eot) goto def;
|
2014-08-27 07:38:28 -07:00
|
|
|
parse_class(ls, EOLIAN_CLASS_ABSTRACT);
|
2014-07-01 10:25:17 -07:00
|
|
|
goto found_class;
|
|
|
|
case KW_class:
|
|
|
|
if (eot) goto def;
|
2014-08-27 07:38:28 -07:00
|
|
|
parse_class(ls, EOLIAN_CLASS_REGULAR);
|
2014-07-01 10:25:17 -07:00
|
|
|
goto found_class;
|
|
|
|
case KW_mixin:
|
|
|
|
if (eot) goto def;
|
2014-08-27 07:38:28 -07:00
|
|
|
parse_class(ls, EOLIAN_CLASS_MIXIN);
|
2014-07-01 10:25:17 -07:00
|
|
|
goto found_class;
|
|
|
|
case KW_interface:
|
|
|
|
if (eot) goto def;
|
2014-08-27 07:38:28 -07:00
|
|
|
parse_class(ls, EOLIAN_CLASS_INTERFACE);
|
2014-07-01 10:25:17 -07:00
|
|
|
goto found_class;
|
2015-05-19 06:25:45 -07:00
|
|
|
case KW_import:
|
|
|
|
{
|
2015-05-22 08:34:48 -07:00
|
|
|
Eina_Bool is_eo = EINA_FALSE;
|
2015-05-19 07:26:53 -07:00
|
|
|
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");
|
2015-05-19 07:44:33 -07:00
|
|
|
if (!(found = eina_hash_find(_tfilenames, eina_strbuf_string_get(buf))))
|
2015-05-19 07:26:53 -07:00
|
|
|
{
|
2015-05-22 08:34:48 -07:00
|
|
|
size_t buflen = eina_strbuf_length_get(buf);
|
|
|
|
eina_strbuf_remove(buf, buflen - 1, buflen);
|
|
|
|
if (!(found = eina_hash_find(_filenames, 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);
|
|
|
|
}
|
|
|
|
else is_eo = EINA_TRUE;
|
2015-05-19 07:26:53 -07:00
|
|
|
}
|
2015-05-20 07:41:07 -07:00
|
|
|
if (eina_hash_find(_parsingeos, found))
|
2015-05-19 07:26:53 -07:00
|
|
|
{
|
|
|
|
pop_strbuf(ls);
|
|
|
|
snprintf(errbuf, sizeof(errbuf),
|
2015-05-19 07:44:33 -07:00
|
|
|
"cyclic import '%s'", ls->t.value.s);
|
2015-05-19 07:26:53 -07:00
|
|
|
eo_lexer_syntax_error(ls, errbuf);
|
|
|
|
}
|
|
|
|
pop_strbuf(ls);
|
2015-05-22 09:09:14 -07:00
|
|
|
if (!eo_parser_database_fill(found, !is_eo))
|
2015-05-19 07:26:53 -07:00
|
|
|
{
|
|
|
|
pop_strbuf(ls);
|
|
|
|
snprintf(errbuf, sizeof(errbuf),
|
|
|
|
"error while parsing import '%s'", ls->t.value.s);
|
|
|
|
eo_lexer_syntax_error(ls, errbuf);
|
|
|
|
}
|
|
|
|
pop_strbuf(ls);
|
2015-05-19 06:25:45 -07:00
|
|
|
eo_lexer_get(ls);
|
|
|
|
check_next(ls, ';');
|
|
|
|
break;
|
|
|
|
}
|
2014-07-01 10:25:17 -07:00
|
|
|
case KW_type:
|
|
|
|
{
|
2014-07-21 08:53:25 -07:00
|
|
|
database_type_add(parse_typedef(ls));
|
2016-03-01 07:37:57 -08:00
|
|
|
pop_typedecl(ls);
|
2014-06-20 06:38:57 -07:00
|
|
|
break;
|
2014-07-01 10:25:17 -07:00
|
|
|
}
|
2017-04-07 09:54:55 -07:00
|
|
|
case KW_function:
|
|
|
|
{
|
|
|
|
database_type_add(parse_function_pointer(ls));
|
|
|
|
pop_typedecl(ls);
|
|
|
|
break;
|
|
|
|
}
|
2014-08-08 07:57:39 -07:00
|
|
|
case KW_const:
|
|
|
|
case KW_var:
|
|
|
|
{
|
|
|
|
database_var_add(parse_variable(ls, ls->t.kw == KW_var));
|
2014-09-12 07:01:10 -07:00
|
|
|
ls->tmp.var = NULL;
|
2014-08-08 07:57:39 -07:00
|
|
|
break;
|
|
|
|
}
|
2014-07-08 07:02:36 -07:00
|
|
|
case KW_struct:
|
2014-08-11 06:56:50 -07:00
|
|
|
case KW_enum:
|
2014-07-08 07:02:36 -07:00
|
|
|
{
|
2014-08-11 06:56:50 -07:00
|
|
|
Eina_Bool is_enum = (ls->t.kw == KW_enum);
|
2014-07-08 07:44:42 -07:00
|
|
|
const char *name;
|
2014-07-22 07:27:11 -07:00
|
|
|
int line, col;
|
2015-05-15 07:10:58 -07:00
|
|
|
Eolian_Declaration *decl;
|
2014-08-19 07:55:31 -07:00
|
|
|
Eina_Bool has_extern;
|
|
|
|
const char *freefunc;
|
2014-07-21 07:11:19 -07:00
|
|
|
Eina_Strbuf *buf;
|
2014-07-08 07:02:36 -07:00
|
|
|
eo_lexer_get(ls);
|
2015-05-12 08:15:29 -07:00
|
|
|
parse_struct_attrs(ls, is_enum, &has_extern, &freefunc);
|
2014-07-21 07:11:19 -07:00
|
|
|
buf = push_strbuf(ls);
|
2014-07-22 07:27:11 -07:00
|
|
|
eo_lexer_context_push(ls);
|
2014-07-21 08:53:25 -07:00
|
|
|
line = ls->line_number;
|
|
|
|
col = ls->column;
|
2014-07-21 07:11:19 -07:00
|
|
|
parse_name(ls, buf);
|
2014-07-22 06:48:08 -07:00
|
|
|
name = eina_stringshare_add(eina_strbuf_string_get(buf));
|
2015-05-15 07:10:58 -07:00
|
|
|
decl = (Eolian_Declaration *)eina_hash_find(_decls, name);
|
|
|
|
if (decl)
|
2014-07-21 08:53:25 -07:00
|
|
|
{
|
2014-07-22 06:48:08 -07:00
|
|
|
eina_stringshare_del(name);
|
2014-07-22 07:27:11 -07:00
|
|
|
eo_lexer_context_restore(ls);
|
2015-05-15 07:10:58 -07:00
|
|
|
redef_error(ls, decl, is_enum ? EOLIAN_DECL_ENUM : EOLIAN_DECL_STRUCT);
|
2014-07-21 08:53:25 -07:00
|
|
|
}
|
2014-07-22 07:27:11 -07:00
|
|
|
eo_lexer_context_pop(ls);
|
2014-07-21 07:11:19 -07:00
|
|
|
pop_strbuf(ls);
|
2015-06-03 04:01:08 -07:00
|
|
|
if (!is_enum && ls->t.token == ';')
|
2014-08-13 08:43:18 -07:00
|
|
|
{
|
2016-03-01 07:37:57 -08:00
|
|
|
Eolian_Typedecl *def = push_typedecl(ls);
|
2014-08-19 07:55:31 -07:00
|
|
|
def->is_extern = has_extern;
|
2016-03-01 07:37:57 -08:00
|
|
|
def->type = EOLIAN_TYPEDECL_STRUCT_OPAQUE;
|
2014-08-19 07:55:31 -07:00
|
|
|
def->freefunc = freefunc;
|
2014-08-19 08:37:29 -07:00
|
|
|
pop_str(ls);
|
2014-11-21 06:12:40 -08:00
|
|
|
_fill_name(name, &def->full_name, &def->name, &def->namespaces);
|
2014-08-13 08:43:18 -07:00
|
|
|
eo_lexer_get(ls);
|
2015-06-03 07:35:13 -07:00
|
|
|
FILL_DOC(ls, def, doc);
|
2015-02-18 07:41:50 -08:00
|
|
|
FILL_BASE(def->base, ls, line, col);
|
2014-08-13 08:43:18 -07:00
|
|
|
database_struct_add(def);
|
2016-03-01 07:37:57 -08:00
|
|
|
pop_typedecl(ls);
|
2014-08-13 08:43:18 -07:00
|
|
|
break;
|
|
|
|
}
|
2014-08-11 06:56:50 -07:00
|
|
|
if (is_enum)
|
2014-08-19 07:55:31 -07:00
|
|
|
parse_enum(ls, name, has_extern, line, col);
|
2014-08-11 06:56:50 -07:00
|
|
|
else
|
2014-08-19 07:55:31 -07:00
|
|
|
parse_struct(ls, name, has_extern, line, col, freefunc);
|
2016-03-01 07:37:57 -08:00
|
|
|
pop_typedecl(ls);
|
2014-07-08 17:31:49 -07:00
|
|
|
break;
|
2014-07-08 07:02:36 -07:00
|
|
|
}
|
2014-07-01 10:25:17 -07:00
|
|
|
def:
|
|
|
|
default:
|
|
|
|
eo_lexer_syntax_error(ls, "invalid token");
|
|
|
|
break;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
2014-07-30 03:57:11 -07:00
|
|
|
return EINA_FALSE;
|
2014-06-20 06:38:57 -07:00
|
|
|
found_class:
|
2015-06-01 06:32:19 -07:00
|
|
|
database_decl_add(ls->tmp.kls->full_name, EOLIAN_DECL_CLASS,
|
|
|
|
ls->tmp.kls->base.file, ls->tmp.kls);
|
2014-07-30 03:57:11 -07:00
|
|
|
return EINA_TRUE;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-24 05:45:51 -07:00
|
|
|
parse_chunk(Eo_Lexer *ls, Eina_Bool eot)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2014-07-16 08:06:04 -07:00
|
|
|
while (ls->t.token >= 0)
|
2014-07-30 03:57:11 -07:00
|
|
|
/* set eot to EINA_TRUE so that we only allow parsing of one class */
|
|
|
|
if (parse_unit(ls, eot))
|
|
|
|
eot = EINA_TRUE;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
|
|
|
|
2017-01-20 04:39:45 -08:00
|
|
|
const Eolian_Class *
|
|
|
|
_get_impl_class(const Eolian_Class *cl, const char *cln)
|
|
|
|
{
|
|
|
|
if (!cl || !strcmp(cl->full_name, cln))
|
|
|
|
return cl;
|
|
|
|
Eina_List *l;
|
|
|
|
const char *s;
|
|
|
|
EINA_LIST_FOREACH(cl->inherits, l, s)
|
|
|
|
{
|
|
|
|
/* we can do a depth first search, it's easier and doesn't matter
|
|
|
|
* which part of the inheritance tree we find the class in
|
|
|
|
*/
|
2017-05-24 07:36:23 -07:00
|
|
|
/* FIXME: pass unit properly */
|
|
|
|
const Eolian_Class *fcl = _get_impl_class(eolian_class_get_by_name(NULL, s), cln);
|
2017-01-20 04:39:45 -08:00
|
|
|
if (fcl)
|
|
|
|
return fcl;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_print_linecol(const Eolian_Object *base)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "eolian:%s:%d:%d: ", base->file, base->line, base->column);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_implement(Eolian_Class *cl, Eolian_Implement *impl)
|
|
|
|
{
|
|
|
|
Eolian_Function_Type ftype = EOLIAN_METHOD;
|
|
|
|
|
|
|
|
if (impl->is_prop_get && impl->is_prop_set)
|
|
|
|
ftype = EOLIAN_PROPERTY;
|
|
|
|
else if (impl->is_prop_get)
|
|
|
|
ftype = EOLIAN_PROP_GET;
|
|
|
|
else if (impl->is_prop_set)
|
|
|
|
ftype = EOLIAN_PROP_SET;
|
|
|
|
|
|
|
|
size_t imlen = strlen(impl->full_name);
|
|
|
|
char *clbuf = alloca(imlen + 1);
|
|
|
|
memcpy(clbuf, impl->full_name, imlen + 1);
|
|
|
|
|
|
|
|
char *ldot = strrchr(clbuf, '.');
|
|
|
|
if (!ldot)
|
|
|
|
return EINA_FALSE; /* unreachable in practice, for static analysis */
|
|
|
|
|
|
|
|
*ldot = '\0'; /* split between class name and func name */
|
|
|
|
const char *clname = clbuf;
|
|
|
|
const char *fnname = ldot + 1;
|
|
|
|
|
|
|
|
const Eolian_Class *tcl = _get_impl_class(cl, clname);
|
|
|
|
if (!tcl)
|
|
|
|
{
|
|
|
|
_print_linecol(&impl->base);
|
|
|
|
fprintf(stderr, "class '%s' not found within the inheritance tree of '%s'\n",
|
|
|
|
clname, cl->full_name);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl->klass = tcl;
|
|
|
|
|
|
|
|
const Eolian_Function *fid = eolian_class_function_get_by_name(tcl, fnname, EOLIAN_UNRESOLVED);
|
|
|
|
if (!fid)
|
|
|
|
{
|
|
|
|
_print_linecol(&impl->base);
|
|
|
|
fprintf(stderr, "function '%s' not known in class '%s'\n", fnname, clname);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Eolian_Function_Type aftype = eolian_function_type_get(fid);
|
|
|
|
|
|
|
|
Eina_Bool auto_empty = (impl->get_auto || impl->get_empty);
|
|
|
|
|
|
|
|
/* match implement type against function type */
|
|
|
|
if (ftype == EOLIAN_PROPERTY)
|
|
|
|
{
|
|
|
|
/* property */
|
|
|
|
if (aftype != EOLIAN_PROPERTY)
|
|
|
|
{
|
|
|
|
_print_linecol(&impl->base);
|
|
|
|
fprintf(stderr, "function '%s' is not a complete property", fnname);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
auto_empty = auto_empty && (impl->set_auto || impl->set_empty);
|
|
|
|
}
|
|
|
|
else if (ftype == EOLIAN_PROP_SET)
|
|
|
|
{
|
|
|
|
/* setter */
|
|
|
|
if ((aftype != EOLIAN_PROP_SET) && (aftype != EOLIAN_PROPERTY))
|
|
|
|
{
|
|
|
|
_print_linecol(&impl->base);
|
|
|
|
fprintf(stderr, "function '%s' doesn't have a setter\n", fnname);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
auto_empty = (impl->set_auto || impl->set_empty);
|
|
|
|
}
|
|
|
|
else if (ftype == EOLIAN_PROP_GET)
|
|
|
|
{
|
|
|
|
/* getter */
|
|
|
|
if ((aftype != EOLIAN_PROP_GET) && (aftype != EOLIAN_PROPERTY))
|
|
|
|
{
|
|
|
|
_print_linecol(&impl->base);
|
|
|
|
fprintf(stderr, "function '%s' doesn't have a getter\n", fnname);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aftype != EOLIAN_METHOD)
|
|
|
|
{
|
|
|
|
_print_linecol(&impl->base);
|
|
|
|
fprintf(stderr, "function '%s' is not a method\n", fnname);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((fid->klass == cl) && !auto_empty)
|
|
|
|
{
|
|
|
|
/* only allow explicit implements from other classes, besides auto and
|
|
|
|
* empty... also prevents pure virtuals from being implemented
|
|
|
|
*/
|
|
|
|
_print_linecol(&impl->base);
|
|
|
|
fprintf(stderr, "invalid implement '%s'\n", impl->full_name);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl->foo_id = fid;
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_implements(Eolian_Class *cl)
|
|
|
|
{
|
|
|
|
Eolian_Implement *impl;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
Eina_Bool ret = EINA_TRUE;
|
|
|
|
|
|
|
|
Eina_Hash *th = eina_hash_string_small_new(NULL),
|
|
|
|
*pth = eina_hash_string_small_new(NULL);
|
|
|
|
EINA_LIST_FOREACH(cl->implements, l, impl)
|
|
|
|
{
|
|
|
|
Eina_Bool prop = (impl->is_prop_get || impl->is_prop_set);
|
|
|
|
if (eina_hash_find(prop ? pth : th, impl->full_name))
|
|
|
|
{
|
|
|
|
_print_linecol(&impl->base);
|
|
|
|
fprintf(stderr, "duplicate implement '%s'\n", impl->full_name);
|
|
|
|
ret = EINA_FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if (impl->klass != cl)
|
|
|
|
{
|
|
|
|
if (!_db_fill_implement(cl, impl))
|
|
|
|
{
|
|
|
|
ret = EINA_FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
if (eolian_function_is_constructor(impl->foo_id, impl->klass))
|
|
|
|
database_function_constructor_add((Eolian_Function *)impl->foo_id, cl);
|
|
|
|
}
|
|
|
|
if ((impl->klass != cl) && !_db_fill_implement(cl, impl))
|
|
|
|
{
|
|
|
|
ret = EINA_FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
eina_hash_add(prop ? pth : th, impl->full_name, impl->full_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
eina_hash_free(th);
|
|
|
|
eina_hash_free(pth);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_db_fill_ctors(Eolian_Class *cl)
|
|
|
|
{
|
|
|
|
Eolian_Constructor *ctor;
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
Eina_Bool ret = EINA_TRUE;
|
|
|
|
|
|
|
|
Eina_Hash *th = eina_hash_string_small_new(NULL);
|
|
|
|
EINA_LIST_FOREACH(cl->constructors, l, ctor)
|
|
|
|
{
|
|
|
|
if (eina_hash_find(th, ctor->full_name))
|
|
|
|
{
|
|
|
|
_print_linecol(&ctor->base);
|
|
|
|
fprintf(stderr, "duplicate ctor '%s'\n", ctor->full_name);
|
|
|
|
ret = EINA_FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
const char *ldot = strrchr(ctor->full_name, '.');
|
|
|
|
if (!ldot)
|
|
|
|
{
|
|
|
|
ret = EINA_FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
char *cnbuf = alloca(ldot - ctor->full_name + 1);
|
|
|
|
memcpy(cnbuf, ctor->full_name, ldot - ctor->full_name);
|
|
|
|
cnbuf[ldot - ctor->full_name] = '\0';
|
|
|
|
const Eolian_Class *tcl = _get_impl_class(cl, cnbuf);
|
|
|
|
if (!tcl)
|
|
|
|
{
|
|
|
|
_print_linecol(&ctor->base);
|
|
|
|
fprintf(stderr, "class '%s' not found within the inheritance "
|
|
|
|
"tree of '%s'\n", cnbuf, cl->full_name);
|
|
|
|
ret = EINA_FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
ctor->klass = tcl;
|
|
|
|
const Eolian_Function *cfunc = eolian_constructor_function_get(ctor);
|
|
|
|
if (!cfunc)
|
|
|
|
{
|
|
|
|
_print_linecol(&ctor->base);
|
|
|
|
fprintf(stderr, "unable to find function '%s'\n", ctor->full_name);
|
|
|
|
ret = EINA_FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
database_function_constructor_add((Eolian_Function *)cfunc, tcl);
|
|
|
|
eina_hash_add(th, ctor->full_name, ctor->full_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
eina_hash_free(th);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-06-18 03:25:07 -07:00
|
|
|
Eina_Bool
|
2017-01-20 04:39:45 -08:00
|
|
|
eo_parser_database_fill(const char *filename, Eina_Bool eot)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2017-01-20 04:39:45 -08:00
|
|
|
if (eina_hash_find(_parsedeos, filename))
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
eina_hash_set(_parsingeos, filename, (void *)EINA_TRUE);
|
|
|
|
|
|
|
|
Eo_Lexer *ls = eo_lexer_new(filename);
|
|
|
|
if (!ls)
|
2014-06-18 03:25:07 -07:00
|
|
|
{
|
2017-01-20 04:39:45 -08:00
|
|
|
fprintf(stderr, "eolian: unable to create lexer for file '%s'\n", filename);
|
|
|
|
goto error;
|
2014-06-18 03:25:07 -07:00
|
|
|
}
|
2017-01-20 04:39:45 -08:00
|
|
|
|
|
|
|
/* read first token */
|
|
|
|
eo_lexer_get(ls);
|
|
|
|
|
|
|
|
if (setjmp(ls->err_jmp))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
parse_chunk(ls, eot);
|
|
|
|
if (eot) goto done;
|
|
|
|
|
|
|
|
Eolian_Class *cl;
|
|
|
|
|
|
|
|
if (!(cl = ls->tmp.kls))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "eolian: no class for file '%s'\n", filename);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
ls->tmp.kls = NULL;
|
|
|
|
|
|
|
|
if (!_db_fill_implements(cl))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
if (!_db_fill_ctors(cl))
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
eina_hash_set(_classes, cl->full_name, cl);
|
|
|
|
eina_hash_set(_classesf, cl->base.file, cl);
|
|
|
|
|
|
|
|
done:
|
|
|
|
eina_hash_set(_parsedeos, filename, (void *)EINA_TRUE);
|
|
|
|
eina_hash_set(_parsingeos, filename, (void *)EINA_FALSE);
|
|
|
|
|
|
|
|
eo_lexer_free(ls);
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error:
|
|
|
|
eina_hash_set(_parsingeos, filename, (void *)EINA_FALSE);
|
|
|
|
eo_lexer_free(ls);
|
2014-06-18 03:25:07 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|