From 5300633c2b3e814fd49b8b4d2a61373e42cd0b9b Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 17 Nov 1989 11:52:33 +0000 Subject: [PATCH] improved error messages --- lang/m2/comp/LLmessage.c | 2 +- lang/m2/comp/make.tokcase | 27 +++++++++++++++++---------- lang/m2/m2mm/LLmessage.c | 10 ++++------ lang/m2/m2mm/make.tokcase | 27 +++++++++++++++++---------- 4 files changed, 39 insertions(+), 27 deletions(-) diff --git a/lang/m2/comp/LLmessage.c b/lang/m2/comp/LLmessage.c index 48b282791..add039c8f 100644 --- a/lang/m2/comp/LLmessage.c +++ b/lang/m2/comp/LLmessage.c @@ -34,7 +34,7 @@ LLmessage(tk) */ register t_token *dotp = ˙ - error("%s missing", symbol2str(tk)); + error("%s missing before %s", symbol2str(tk), symbol2str(dotp->tk_symb)); aside = *dotp; diff --git a/lang/m2/comp/make.tokcase b/lang/m2/comp/make.tokcase index ef32292f9..56d104ae2 100755 --- a/lang/m2/comp/make.tokcase +++ b/lang/m2/comp/make.tokcase @@ -1,34 +1,41 @@ cat <<'--EOT--' +/* Generated by make.tokcase */ +/* $Header$ */ #include "Lpars.h" char * symbol2str(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) { --EOT-- + sed ' /{[A-Z]/!d s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\ return \2;/ ' + cat <<'--EOT--' + default: + if (tok <= 0) return "end of file"; + if (tok < 040 || tok >= 0177) { + return "bad token"; + } + /* fall through */ case '\n': case '\f': case '\v': case '\r': case '\t': - buf[0] = tok; - return buf; - default: - return "bad token"; + index = (index+2) & (SIZBUF-1); + buf[index] = tok; + return &buf[index]; } } --EOT-- diff --git a/lang/m2/m2mm/LLmessage.c b/lang/m2/m2mm/LLmessage.c index 6a4c25634..8da82d00f 100644 --- a/lang/m2/m2mm/LLmessage.c +++ b/lang/m2/m2mm/LLmessage.c @@ -30,18 +30,16 @@ LLmessage(tk) if (tk > 0) { /* if (tk > 0), it represents the token to be inserted. */ - register struct token *dotp = ˙ + error("%s missing before %s", symbol2str(tk), symbol2str(dot.tk_symb)); - error("%s missing", symbol2str(tk)); + aside = dot; - aside = *dotp; - - dotp->tk_symb = tk; + dot.tk_symb = tk; switch (tk) { /* The operands need some body */ case IDENT: - dotp->TOK_IDF = gen_anon_idf(); + dot.TOK_IDF = gen_anon_idf(); break; } } diff --git a/lang/m2/m2mm/make.tokcase b/lang/m2/m2mm/make.tokcase index ef32292f9..56d104ae2 100755 --- a/lang/m2/m2mm/make.tokcase +++ b/lang/m2/m2mm/make.tokcase @@ -1,34 +1,41 @@ cat <<'--EOT--' +/* Generated by make.tokcase */ +/* $Header$ */ #include "Lpars.h" char * symbol2str(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) { --EOT-- + sed ' /{[A-Z]/!d s/.*{\(.*\),.*\(".*"\).*$/ case \1 :\ return \2;/ ' + cat <<'--EOT--' + default: + if (tok <= 0) return "end of file"; + if (tok < 040 || tok >= 0177) { + return "bad token"; + } + /* fall through */ case '\n': case '\f': case '\v': case '\r': case '\t': - buf[0] = tok; - return buf; - default: - return "bad token"; + index = (index+2) & (SIZBUF-1); + buf[index] = tok; + return &buf[index]; } } --EOT-- -- 2.34.1