improved error messages

This commit is contained in:
ceriel 1989-11-17 11:52:33 +00:00
parent ff90971199
commit 5300633c2b
4 changed files with 39 additions and 27 deletions

View file

@ -34,7 +34,7 @@ LLmessage(tk)
*/ */
register t_token *dotp = ˙ register t_token *dotp = ˙
error("%s missing", symbol2str(tk)); error("%s missing before %s", symbol2str(tk), symbol2str(dotp->tk_symb));
aside = *dotp; aside = *dotp;

View file

@ -1,34 +1,41 @@
cat <<'--EOT--' cat <<'--EOT--'
/* Generated by make.tokcase */
/* $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--
sed ' sed '
/{[A-Z]/!d /{[A-Z]/!d
s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\ s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\
return \2;/ return \2;/
' '
cat <<'--EOT--' cat <<'--EOT--'
default:
if (tok <= 0) return "end of file";
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--

View file

@ -30,18 +30,16 @@ LLmessage(tk)
if (tk > 0) { if (tk > 0) {
/* if (tk > 0), it represents the token to be inserted. /* if (tk > 0), it represents the token to be inserted.
*/ */
register struct token *dotp = &dot; error("%s missing before %s", symbol2str(tk), symbol2str(dot.tk_symb));
error("%s missing", symbol2str(tk)); aside = dot;
aside = *dotp; dot.tk_symb = tk;
dotp->tk_symb = tk;
switch (tk) { switch (tk) {
/* The operands need some body */ /* The operands need some body */
case IDENT: case IDENT:
dotp->TOK_IDF = gen_anon_idf(); dot.TOK_IDF = gen_anon_idf();
break; break;
} }
} }

View file

@ -1,34 +1,41 @@
cat <<'--EOT--' cat <<'--EOT--'
/* Generated by make.tokcase */
/* $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--
sed ' sed '
/{[A-Z]/!d /{[A-Z]/!d
s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\ s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\
return \2;/ return \2;/
' '
cat <<'--EOT--' cat <<'--EOT--'
default:
if (tok <= 0) return "end of file";
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--