summaryrefslogtreecommitdiff
path: root/ghc/utils/ugen/yyerror.c
blob: 4b9a0380d11932956fb0bf0e4c85288f3c96f8f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
extern int yylineno;

void
yyerror(s)
    char *s;
{
	extern int yychar;
	extern char yytext[1];

	fprintf(stderr, "\n%s", s);
	if(yylineno)
		fprintf(stderr, ", line %d, ", yylineno);
	fprintf(stderr, "on input: ");
	if( yychar >= 0400 )
		fprintf(stderr, "%s\n", &yytext[0]);
	else
		switch(yychar) {
		  case '\t' : fprintf(stderr, "\\t\n"); break;
		  case '\n' : fprintf(stderr, "\\n\n"); break;
		  case '\0' : fprintf(stderr, "$end\n"); break;
		  default   : fprintf(stderr, "%c\n", yychar); break;
		}
}