fixed error messages by allowing more than one "simultaneous" symbol2str

This commit is contained in:
ceriel 1989-11-17 11:31:05 +00:00
parent 676fee0a3e
commit a43e504fb1
2 changed files with 15 additions and 12 deletions

View file

@ -91,6 +91,7 @@ initial_value_pack(struct type **tpp; struct expr **expp;)
initial_value_list(register struct type **tpp; struct expr **expp;) initial_value_list(register struct type **tpp; struct expr **expp;)
{ struct expr *e1; { struct expr *e1;
register struct type **tpp2 = 0; register struct type **tpp2 = 0;
int err_flag = gen_error;
} }
: :
{ if (tpp) tpp2 = gen_tphead(tpp, 0); } { if (tpp) tpp2 = gen_tphead(tpp, 0); }
@ -102,7 +103,7 @@ initial_value_list(register struct type **tpp; struct expr **expp;)
initial_value(tpp2, &e1) initial_value(tpp2, &e1)
{ if (!tpp) init_expression(&expp, e1); } { if (!tpp) init_expression(&expp, e1); }
]* ]*
{ if (tpp) gen_tpend(); } { if (tpp && ! err_flag) gen_tpend(); }
','? /* optional trailing comma */ ','? /* optional trailing comma */
; ;

View file

@ -1,19 +1,17 @@
cat <<'--EOT--' cat <<'--EOT--'
/* Generated by make.tokcase */ /* Generated by make.tokcase */
/* $Header: */ /* $Header$ */
#include "Lpars.h" #include "Lpars.h"
char * char *
symbol2str(tok) symbol2str(tok)
int tok; int tok;
{ {
static char buf[2] = { '\0', '\0' }; #define SIZBUF 8
/* allow for a few invocations in f.i. an argument list */
static char buf[SIZBUF];
static int index;
if (040 <= tok && tok < 0177) {
buf[0] = tok;
buf[1] = '\0';
return buf;
}
switch (tok) { switch (tok) {
--EOT-- --EOT--
@ -24,15 +22,19 @@ s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\
' '
cat <<'--EOT--' cat <<'--EOT--'
default:
if (tok < 040 || tok >= 0177) {
return "bad token";
}
/* fall through */
case '\n': case '\n':
case '\f': case '\f':
case '\v': case '\v':
case '\r': case '\r':
case '\t': case '\t':
buf[0] = tok; index = (index+2) & (SIZBUF-1);
return buf; buf[index] = tok;
default: return &buf[index];
return "bad token";
} }
} }
--EOT-- --EOT--