diff options
Diffstat (limited to 'noao/digiphot/photcal/parser/prerror.x')
-rw-r--r-- | noao/digiphot/photcal/parser/prerror.x | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/noao/digiphot/photcal/parser/prerror.x b/noao/digiphot/photcal/parser/prerror.x new file mode 100644 index 00000000..8821810e --- /dev/null +++ b/noao/digiphot/photcal/parser/prerror.x @@ -0,0 +1,57 @@ +include "../lib/parser.h" +include "../lib/prdefs.h" + + +# PR_ERROR - Issue an error message to the standard output, and take an +# error action acording to the severity code. Error messages can be disabled +# if the error flag is set to NO. + +procedure pr_error (msg, severity) + +char msg[ARB] # error message +int severity # severity code + +include "lexer.com" + +#bool clgetb() +int pr_geti() + +begin + # Debug ? + #if (clgetb ("debug.parcode")) { + #call eprintf ("pr_error (msg=%s) (sev=%d)\n") + #call pargstr (msg) + #call pargi (severity) + #} + + # Test whether to process errors, or not + if (pr_geti (FLAGERRORS) == NO) + return + + # Branch on error severity code + switch (severity) { + case PERR_WARNING: + call pr_inci (NWARNINGS, 1) + call printf ("** Warning near line %d: %s%s\n") + call pargi (nlines) + call pargstr (line) + call pargstr (msg) + case PERR_SYNTAX: + call pr_inci (NERRORS, 1) + call printf ("** Error near line %d: %s%s at '%s'\n") + call pargi (nlines) + call pargstr (line) + call pargstr (msg) + call pargstr (id) + case PERR_SEMANTIC: + call pr_inci (NERRORS, 1) + call printf ("** Error near line %d: %s%s\n") + call pargi (nlines) + call pargstr (line) + call pargstr (msg) + case PERR_POSTPROC: + call pr_inci (NERRORS, 1) + call printf ("** Error: %s\n") + call pargstr (msg) + } +end |