eolian: use eina logging for error messages
authorDaniel Kolesa <d.kolesa@samsung.com>
Thu, 3 Jul 2014 00:48:00 +0000 (01:48 +0100)
committerDaniel Kolesa <d.kolesa@samsung.com>
Thu, 3 Jul 2014 00:48:00 +0000 (01:48 +0100)
src/lib/eolian/eo_lexer.c
src/lib/eolian/eo_parser.c

index 423b521..bbeda56 100644 (file)
@@ -74,18 +74,22 @@ static void
 throw(Eo_Lexer *ls, const char *fmt, ...)
 {
    const char *ln = ls->stream_line, *end = ls->stream_end;
+   Eina_Strbuf *buf = eina_strbuf_new();
    int i;
    va_list ap;
    va_start(ap, fmt);
-   vfprintf(stderr, fmt, ap);
+   eina_strbuf_append_vprintf(buf, fmt, ap);
    va_end(ap);
-   fputc(' ', stderr);
+   eina_strbuf_append_char(buf, ' ');
    while (ln != end && !is_newline(*ln))
-     fputc(*(ln++), stderr);
-   fputc('\n', stderr);
+     eina_strbuf_append_char(buf,*(ln++));
+   eina_strbuf_append_char(buf, '\n');
    for (i = 0; i < ls->column; ++i)
-     fputc(' ', stderr);
-   fputs("^\n", stderr);
+     eina_strbuf_append_char(buf, ' ');
+   eina_strbuf_append(buf, "^\n");
+   eina_log_print(_eo_lexer_log_dom, EINA_LOG_LEVEL_ERR, ls->source, "",
+                  ls->line_number, eina_strbuf_string_get(buf));
+   eina_strbuf_free(buf);
    longjmp(ls->err_jmp, EINA_TRUE);
 }
 
@@ -318,7 +322,10 @@ eo_lexer_set_input(Eo_Lexer *ls, const char *source)
 {
    Eina_File *f = eina_file_open(source, EINA_FALSE);
    if (!f)
-     throw(ls, "%s\n", strerror(errno));
+     {
+        ERR("%s", strerror(errno));
+        longjmp(ls->err_jmp, EINA_TRUE);
+     }
    ls->lookahead.token = TOK_EOF;
    ls->buff            = eina_strbuf_new();
    ls->handle          = f;
@@ -430,11 +437,10 @@ eo_lexer_lex_error(Eo_Lexer *ls, const char *msg, int token)
      {
         char buf[256];
         txt_token(ls, token, buf);
-        throw(ls, "%s:%d:%d: %s near '%s'\n", ls->source, ls->line_number,
-              ls->column, msg, buf);
+        throw(ls, "%s at column %d near '%s'\n", msg, ls->column, buf);
      }
    else
-     throw(ls, "%s:%d:%d: %s\n", ls->source, ls->line_number, ls->column, msg);
+     throw(ls, "%s at column %d\n", msg, ls->column);
 }
 
 void
index e2b24c9..bfab882 100644 (file)
@@ -78,7 +78,7 @@ check_match(Eo_Lexer *ls, int what, int who, int where, int col)
              eo_lexer_token_to_str(what, tbuf);
              eo_lexer_token_to_str(who , vbuf);
              snprintf(buf, sizeof(buf),
-                      "'%s' expected to close '%s' at line %d (column %d)",
+                      "'%s' expected (to close '%s' at line %d at column %d)",
                       tbuf, vbuf, where, col);
              eo_lexer_syntax_error(ls, buf);
           }