From 79b8219a7b8a786740a6c57b2d819953bcf261de Mon Sep 17 00:00:00 2001 From: Teddy Date: Tue, 25 Mar 2014 06:57:44 +0800 Subject: verbose error reporting --- main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 463d290..d82d911 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,6 @@ #include #include +#include #include "cibic.tab.h" #include "ast.h" @@ -12,21 +13,20 @@ int yywrap() { } int yyerror(char *s) { + fprintf(stderr, "%s\n", s); } void print_ast() { - yyparse(); if (fname) - printf("AST for file: \"%s\"\n", fname); + fprintf(stderr, "AST for file: \"%s\"\n", fname); else - printf("AST for stdin\n"); - + fprintf(stderr, "AST for stdin\n"); + yyparse(); if (ast_root) { cnode_debug_print(ast_root, 1); } - else - fprintf(stdout, "Syntax Error\n"); + else exit(1); } void print_help() { -- cgit v1.2.3