summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-27 11:25:04 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-27 11:30:51 +0100
commit80000e993e779caf4317cd595c6c4593d2db8857 (patch)
tree2e0d45dde28c446c377c6ad891bc5b3e1b1ab908 /src
parent77e3ac7f82bacdf7da2251625e6badd3b5d2123e (diff)
eolian: better error reporting (include correct token info)
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/eo_lexer.c20
-rw-r--r--src/lib/eolian/eo_lexer.h1
2 files changed, 17 insertions, 4 deletions
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index e83856422d..b0e4eb789d 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -131,10 +131,7 @@ static void
131txt_token(Eo_Lexer *ls, int token, char *buf) 131txt_token(Eo_Lexer *ls, int token, char *buf)
132{ 132{
133 if (token == TOK_VALUE) 133 if (token == TOK_VALUE)
134 { 134 memcpy(buf, ls->t.value.s, strlen(ls->t.value.s) + 1);
135 const char *str = eina_strbuf_string_get(ls->buff);
136 memcpy(buf, str, strlen(str) + 1);
137 }
138 else 135 else
139 return eo_lexer_token_to_str(token, buf); 136 return eo_lexer_token_to_str(token, buf);
140} 137}
@@ -848,6 +845,11 @@ eo_lexer_shutdown()
848 return _init_counter; 845 return _init_counter;
849} 846}
850 847
848static Eina_Bool
849_eo_is_tokstr(int t) {
850 return (t == TOK_COMMENT) || (t == TOK_STRING) || (t == TOK_VALUE);
851}
852
851void 853void
852eo_lexer_context_push(Eo_Lexer *ls) 854eo_lexer_context_push(Eo_Lexer *ls)
853{ 855{
@@ -855,6 +857,9 @@ eo_lexer_context_push(Eo_Lexer *ls)
855 ctx->line = ls->line_number; 857 ctx->line = ls->line_number;
856 ctx->column = ls->column; 858 ctx->column = ls->column;
857 ctx->linestr = ls->stream_line; 859 ctx->linestr = ls->stream_line;
860 ctx->token = ls->t;
861 if (_eo_is_tokstr(ctx->token.token))
862 eina_stringshare_ref(ctx->token.value.s);
858 ls->saved_ctxs = eina_list_prepend(ls->saved_ctxs, ctx); 863 ls->saved_ctxs = eina_list_prepend(ls->saved_ctxs, ctx);
859} 864}
860 865
@@ -862,6 +867,8 @@ void
862eo_lexer_context_pop(Eo_Lexer *ls) 867eo_lexer_context_pop(Eo_Lexer *ls)
863{ 868{
864 Lexer_Ctx *ctx = (Lexer_Ctx*)eina_list_data_get(ls->saved_ctxs); 869 Lexer_Ctx *ctx = (Lexer_Ctx*)eina_list_data_get(ls->saved_ctxs);
870 if (_eo_is_tokstr(ctx->token.token))
871 eina_stringshare_del(ctx->token.value.s);
865 free(ctx); 872 free(ctx);
866 ls->saved_ctxs = eina_list_remove_list(ls->saved_ctxs, ls->saved_ctxs); 873 ls->saved_ctxs = eina_list_remove_list(ls->saved_ctxs, ls->saved_ctxs);
867} 874}
@@ -874,6 +881,11 @@ eo_lexer_context_restore(Eo_Lexer *ls)
874 ls->line_number = ctx->line; 881 ls->line_number = ctx->line;
875 ls->column = ctx->column; 882 ls->column = ctx->column;
876 ls->stream_line = ctx->linestr; 883 ls->stream_line = ctx->linestr;
884 if (_eo_is_tokstr(ls->t.token))
885 eina_stringshare_del(ls->t.value.s);
886 ls->t = ctx->token;
887 if (_eo_is_tokstr(ls->t.token))
888 eina_stringshare_ref(ls->t.value.s);
877} 889}
878 890
879void 891void
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index 0ffda4abbd..2afb8148dc 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -92,6 +92,7 @@ typedef struct _Lexer_Ctx
92{ 92{
93 int line, column; 93 int line, column;
94 const char *linestr; 94 const char *linestr;
95 Eo_Token token;
95} Lexer_Ctx; 96} Lexer_Ctx;
96 97
97typedef struct _Eo_Lexer_Temps 98typedef struct _Eo_Lexer_Temps