summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2010-05-12 19:30:54 +0200
committerJohannes Weiner <hannes@cmpxchg.org>2010-05-12 19:30:54 +0200
commit1e70e852a0b786613f4c791b80fb1ab61239ddcf (patch)
tree33f2b8a43efd74cfbac54e13daaf60f5ae2425e0
parent11a0d33090f99ff5c06a14a18e58529726cf6200 (diff)
parse: report errors `file:line: expression: message' style
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
-rw-r--r--sheep/parse.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sheep/parse.c b/sheep/parse.c
index a5e3f0e..1080142 100644
--- a/sheep/parse.c
+++ b/sheep/parse.c
@@ -31,16 +31,17 @@ void sheep_parser_error(struct sheep_compile *compile, sheep_t culprit,
} else
position = 0;
- fprintf(stderr, "%s:%lu: ", expr->filename,
- (unsigned long)expr->lines.items[position]);
+ repr = sheep_repr(culprit);
+ fprintf(stderr, "%s:%lu: %s: ", expr->filename,
+ (unsigned long)expr->lines.items[position],
+ repr);
+ sheep_free(repr);
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
- repr = sheep_repr(culprit);
- fprintf(stderr, " `%s'\n", repr);
- sheep_free(repr);
+ fprintf(stderr, "\n");
}
enum {
@@ -121,9 +122,9 @@ static int parse(struct sheep_compile *compile, struct sheep_list *form,
return 0;
if (ret == PARSE_MISMATCH)
- sheep_parser_error(compile, mismatch, "parser error at");
+ sheep_parser_error(compile, mismatch, "unexpected expression");
else
- sheep_parser_error(compile, form->head, "too %s arguments to",
+ sheep_parser_error(compile, form->head, "too %s arguments",
ret == PARSE_TOO_MANY ? "many" : "few");
return -1;