aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2014-03-25 06:57:44 +0800
committerTeddy <ted.sybil@gmail.com>2014-03-25 06:57:44 +0800
commit79b8219a7b8a786740a6c57b2d819953bcf261de (patch)
treea0e81987d32f5748ff99de2c67dd543abd42417f /main.c
parent04ee9c8bef572f4351090b768413e5b6a3ac4a77 (diff)
verbose error reporting
Diffstat (limited to 'main.c')
-rw-r--r--main.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/main.c b/main.c
index 463d290..d82d911 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <getopt.h>
+#include <stdlib.h>
#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() {