From 7a2a3bf748e7f4511a597ec33100c50703baeeec Mon Sep 17 00:00:00 2001 From: Francesco Romani Date: Sat, 5 Jul 2014 18:19:59 +0200 Subject: orcc: switch to orc_parse_code orc_parse_code has much better error report than orc_parse_full, so orcc should make use of it. Part-of: --- tools/orcc.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/tools/orcc.c b/tools/orcc.c index 36b0adc..8da7ad6 100644 --- a/tools/orcc.c +++ b/tools/orcc.c @@ -94,14 +94,14 @@ main (int argc, char *argv[]) { const char *orc_version; char *code; - int n; int i; char *output_file = NULL; char *input_file = NULL; char *include_file = NULL; char *compat_version = VERSION; FILE *output; - char *log = NULL; + OrcParseError **errors = NULL; + int n_errors = 0; orc_init (); @@ -257,11 +257,16 @@ main (int argc, char *argv[]) exit(1); } - n = orc_parse_full (code, &programs, &log); + orc_parse_code (code, &programs, &n_programs, &errors, &n_errors); free(code); - n_programs = n; - printf("%s", log); - free(log); + if (n_errors > 0) { + int i; + for (i=0;isource, errors[i]->line_number, errors[i]->text); + } + orc_parse_error_freev (errors); + exit (1); + } if (programs == NULL) { printf("no programs\n"); @@ -299,7 +304,7 @@ main (int argc, char *argv[]) fprintf(output, "#ifndef DISABLE_ORC\n"); fprintf(output, "#include \n"); fprintf(output, "#endif\n"); - for(i=0;i\n"); fprintf(output, "\n"); - for(i=0;iname); output_code_backup (programs[i], output); } @@ -412,7 +417,7 @@ main (int argc, char *argv[]) fprintf(output, " }\n"); fprintf(output, " }\n"); fprintf(output, "\n"); - for(i=0;i