1/*
2 * errsupport.c -- error support code for SORCERER output
3 *
4 * Define your own or compile and link this in.
5 *
6 * Terence Parr
7 * U of MN, AHPCRC
8 * February 1994
9 */
10#include "sorcerer.h"
11
12void
13#ifdef __USE_PROTOS
14mismatched_range( STreeParser *_parser, int looking_for, int upper_token, SORAST *found )
15#else
16mismatched_range( _parser, looking_for, upper_token, found )
17int looking_for;
18int upper_token;
19SORAST *found;
20STreeParser *_parser;
21#endif
22{
23  if ( found!=NULL ) {
24    fprintf(stderr,
25        "parse error: expected token range %d..%d found token %d\n",
26        looking_for, upper_token,
27        found->token);
28  }
29  else {
30    fprintf(stderr,
31        "parse error: expected token range %d..%d found NULL tree\n",
32        looking_for, upper_token);
33  }
34}
35
36void
37#ifdef __USE_PROTOS
38missing_wildcard(STreeParser *_parser)
39#else
40missing_wildcard(_parser)
41STreeParser *_parser;
42#endif
43{
44  fprintf(stderr, "parse error: expected any token/tree found found NULL tree\n");
45}
46
47void
48#ifdef __USE_PROTOS
49mismatched_token( STreeParser *_parser, int looking_for, SORAST *found )
50#else
51mismatched_token( _parser, looking_for, found )
52int looking_for;
53SORAST *found;
54STreeParser *_parser;
55#endif
56{
57  if ( found!=NULL ) {
58    fprintf(stderr,
59        "parse error: expected token %d found token %d\n",
60        looking_for,
61        found->token);
62  }
63  else {
64    fprintf(stderr,
65        "parse error: expected token %d found NULL tree\n",
66        looking_for);
67  }
68}
69
70void
71#ifdef __USE_PROTOS
72no_viable_alt( STreeParser *_parser, char *rulename, SORAST *root )
73#else
74no_viable_alt( _parser, rulename, root )
75char *rulename;
76SORAST *root;
77STreeParser *_parser;
78#endif
79{
80  if ( root==NULL )
81    fprintf(stderr,
82        "parse error: in rule %s, no viable alternative for NULL tree\n",
83        rulename);
84  else
85    fprintf(stderr,
86        "parse error: in rule %s, no viable alternative for tree\n",
87        rulename);
88}
89
90void
91#ifdef __USE_PROTOS
92sorcerer_panic(char *err)
93#else
94sorcerer_panic(err)
95char *err;
96#endif
97{
98  fprintf(stderr, "panic: %s\n", err);
99  exit(-1);
100}
101