q66 pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=80000e993e779caf4317cd595c6c4593d2db8857

commit 80000e993e779caf4317cd595c6c4593d2db8857
Author: Daniel Kolesa <d.kol...@osg.samsung.com>
Date:   Wed May 27 11:25:04 2015 +0100

    eolian: better error reporting (include correct token info)
---
 src/lib/eolian/eo_lexer.c | 20 ++++++++++++++++----
 src/lib/eolian/eo_lexer.h |  1 +
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index e838564..b0e4eb7 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -131,10 +131,7 @@ static void
 txt_token(Eo_Lexer *ls, int token, char *buf)
 {
    if (token == TOK_VALUE)
-     {
-        const char *str = eina_strbuf_string_get(ls->buff);
-        memcpy(buf, str, strlen(str) + 1);
-     }
+     memcpy(buf, ls->t.value.s, strlen(ls->t.value.s) + 1);
    else
      return eo_lexer_token_to_str(token, buf);
 }
@@ -848,6 +845,11 @@ eo_lexer_shutdown()
    return _init_counter;
 }
 
+static Eina_Bool
+_eo_is_tokstr(int t) {
+    return (t == TOK_COMMENT) || (t == TOK_STRING) || (t == TOK_VALUE);
+}
+
 void
 eo_lexer_context_push(Eo_Lexer *ls)
 {
@@ -855,6 +857,9 @@ eo_lexer_context_push(Eo_Lexer *ls)
    ctx->line = ls->line_number;
    ctx->column = ls->column;
    ctx->linestr = ls->stream_line;
+   ctx->token = ls->t;
+   if (_eo_is_tokstr(ctx->token.token))
+     eina_stringshare_ref(ctx->token.value.s);
    ls->saved_ctxs = eina_list_prepend(ls->saved_ctxs, ctx);
 }
 
@@ -862,6 +867,8 @@ void
 eo_lexer_context_pop(Eo_Lexer *ls)
 {
    Lexer_Ctx *ctx = (Lexer_Ctx*)eina_list_data_get(ls->saved_ctxs);
+   if (_eo_is_tokstr(ctx->token.token))
+     eina_stringshare_del(ctx->token.value.s);
    free(ctx);
    ls->saved_ctxs = eina_list_remove_list(ls->saved_ctxs, ls->saved_ctxs);
 }
@@ -874,6 +881,11 @@ eo_lexer_context_restore(Eo_Lexer *ls)
    ls->line_number = ctx->line;
    ls->column      = ctx->column;
    ls->stream_line = ctx->linestr;
+   if (_eo_is_tokstr(ls->t.token))
+     eina_stringshare_del(ls->t.value.s);
+   ls->t = ctx->token;
+   if (_eo_is_tokstr(ls->t.token))
+     eina_stringshare_ref(ls->t.value.s);
 }
 
 void
diff --git a/src/lib/eolian/eo_lexer.h b/src/lib/eolian/eo_lexer.h
index 0ffda4a..2afb814 100644
--- a/src/lib/eolian/eo_lexer.h
+++ b/src/lib/eolian/eo_lexer.h
@@ -92,6 +92,7 @@ typedef struct _Lexer_Ctx
 {
    int line, column;
    const char *linestr;
+   Eo_Token token;
 } Lexer_Ctx;
 
 typedef struct _Eo_Lexer_Temps

-- 


Reply via email to