version 1.9, 2003/09/29 03:24:27 |
version 1.10, 2003/09/30 18:46:11 |
|
|
void |
void |
yyerror(char *s) |
yyerror(char *s) |
{ |
{ |
if (isspace(*yytext) || !isprint(*yytext)) |
char *str, *p; |
printf("c[%s: %s:%d: %s: ascii char 0x%x unexpected]pc\n", |
|
__progname, filename, lineno, s, *yytext); |
if (isspace(yytext[0]) || !isprint(yytext[0])) |
|
asprintf(&str, "%s: %s:%d: %s: ascii char 0x%x unexpected", |
|
__progname, filename, lineno, s, yytext[0]); |
else |
else |
printf("c[%s: %s:%d: %s: %s unexpected]pc\n", |
asprintf(&str, "%s: %s:%d: %s: %s unexpected", |
__progname, filename, lineno, s, yytext); |
__progname, filename, lineno, s, yytext); |
|
if (str == NULL) |
|
err(1, "cannot allocate string"); |
|
|
|
fputs("c[", stdout); |
|
for (p = str; *p != '\0'; p++) { |
|
if (*p == '[' || *p == ']' || *p =='\\') |
|
putchar('\\'); |
|
putchar(*p); |
|
} |
|
fputs("]pc\n", stdout); |
|
free(str); |
} |
} |
|
|
void |
void |