From a655b8b3ebe77c236048b330ad35ef54a938217e Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Sat, 17 Oct 2015 22:16:43 -0400 Subject: add cheap line reporting in die --- minic/minic.y | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'minic') diff --git a/minic/minic.y b/minic/minic.y index b73e043..ab95604 100644 --- a/minic/minic.y +++ b/minic/minic.y @@ -72,6 +72,7 @@ int yylex(void), yyerror(char *); Symb expr(Node *), lval(Node *); FILE *of; +int line; int lbl, tmp, nglo; char *ini[NGlo]; struct { @@ -83,7 +84,7 @@ struct { void die(char *s) { - fprintf(stderr, "error: %s\n", s); + fprintf(stderr, "error:%d: %s\n", line, s); exit(1); } @@ -796,6 +797,8 @@ yylex() if (c == '#') while ((c = getchar()) != '\n') ; + if (c == '\n') + line++; } while (isspace(c)); -- cgit 1.4.1