From 25dd5857c2f4504c2d2fc39a6f9970efa7964046 Mon Sep 17 00:00:00 2001 From: ceriel Date: Wed, 3 Jun 1987 19:05:14 +0000 Subject: [PATCH] minor changes to many files --- util/LLgen/src/LLgen.g | 9 +++++---- util/LLgen/src/gencode.c | 24 ++++++++++++------------ util/LLgen/src/name.c | 12 +++++++++--- util/LLgen/src/reach.c | 4 ++-- util/LLgen/src/tokens.g | 6 +++--- 5 files changed, 31 insertions(+), 24 deletions(-) diff --git a/util/LLgen/src/LLgen.g b/util/LLgen/src/LLgen.g index 9934d625d..5ef6f6c1a 100644 --- a/util/LLgen/src/LLgen.g +++ b/util/LLgen/src/LLgen.g @@ -149,7 +149,7 @@ rule { register p_nont p; p = &nonterms[g_getcont(temp)]; if (p->n_rule) { error(linecount, -"nonterminal %s already defined", lextoken.t_string); +"Nonterminal %s already defined", lextoken.t_string); } /* * Remember the order in which the nonterminals @@ -360,10 +360,11 @@ simpleproduction(p_gram *p; register int *conflres;) if ((q->t_flags & PERSISTENT) && kind == FIXED) { error(linecount, - "illegal %%persistent"); + "Illegal %%persistent"); } */ } + termdeleted = 0; *p_rule++ = elem; } ]* { register p_term q; @@ -530,7 +531,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; { if (!level) unput(ch); if (level || flag == 1) putc(ch,f); if ((!level) && flag == 2 && !semicolon) { - error(linecount,"missing ';'"); + error(linecount,"Missing ';'"); } return; } @@ -585,7 +586,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; { ch = input(); } if (ch == '\n') { - error(linecount,"newline in string"); + error(linecount,"Newline in string"); unput(match); } putc(ch,f); diff --git a/util/LLgen/src/gencode.c b/util/LLgen/src/gencode.c index 3e5f18230..e67b28441 100644 --- a/util/LLgen/src/gencode.c +++ b/util/LLgen/src/gencode.c @@ -73,6 +73,15 @@ STATIC genincrdecr(); p_mem alloc(); +doclose(f) + FILE *f; +{ + if (ferror(f) != 0) { + fatal(0,"Write error on temporary"); + } + fclose(f); +} + gencode(argc) { register p_file p = files; @@ -90,10 +99,7 @@ gencode(argc) { copyfile(incl_file); generate(p); getaction(2); - if (ferror(fpars) != 0) { - fatal(0,"Write error on temporary"); - } - fclose(fpars); + doclose(fpars); /* And install */ install(genname(p->f_name),p->f_name); p++; @@ -124,10 +130,7 @@ geninclude() { p->t_tokno); } } - if (ferror(fpars) != 0) { - fatal(0,"write error on temporary"); - } - fclose(fpars); + doclose(fpars); install(HFILE, "."); } @@ -204,10 +207,7 @@ genrecovery() { } fputs("#define LL_NEWMESS\n", f); copyfile(rec_file); - if (ferror(f) != 0) { - fatal(0,"write error on temporary"); - } - fclose(f); + doclose(f); install(RFILE, "."); } diff --git a/util/LLgen/src/name.c b/util/LLgen/src/name.c index fa1ea0805..f6cd38bfa 100644 --- a/util/LLgen/src/name.c +++ b/util/LLgen/src/name.c @@ -130,16 +130,22 @@ search(type,str,option) register string str; { if (type1 == LITERAL || type == LITERAL) { continue; } - if (type != UNKNOWN) { + if (type == TERMINAL) { error(linecount, - "%s : illegal type", + "%s: is already a nonterminal", + str); + continue; + } + else if (type == NONTERM) { + error(linecount, + "%s : is already a token", str); continue; } } if (option==ENTERING) { error(linecount, - "%s : already defined",str); + "%s : is already defined",str); } p->h_type.g_lineno = linecount; return &(p->h_type); diff --git a/util/LLgen/src/reach.c b/util/LLgen/src/reach.c index 46ff4ccef..0604c2c51 100644 --- a/util/LLgen/src/reach.c +++ b/util/LLgen/src/reach.c @@ -46,7 +46,7 @@ co_reach() { for (p = nonterms; p < maxnt; p++) { if (! p->n_rule) { /* undefined */ f_input = p->n_string; - error(p->n_lineno,"nonterminal %s not defined", + error(p->n_lineno,"Nonterminal %s not defined", p->n_name); } } @@ -66,7 +66,7 @@ co_reach() { for (s = x->f_list; s; s = s->o_next) { p = &nonterms[s->o_index]; if (! (p->n_flags & REACHABLE)) { - error(p->n_lineno,"nonterminal %s unreachable", + warning(p->n_lineno,"nonterminal %s unreachable", p->n_name); } } diff --git a/util/LLgen/src/tokens.g b/util/LLgen/src/tokens.g index 026232a9b..425ce6c35 100644 --- a/util/LLgen/src/tokens.g +++ b/util/LLgen/src/tokens.g @@ -130,7 +130,7 @@ scanner() { for (;;) { ch = input(); if (ch == '\n' || ch == EOF) { - error(linecount,"missing '"); + error(linecount,"Missing '"); break; } if (ch == '\'') break; @@ -190,7 +190,7 @@ scanner() { } w++; } - error(linecount,"illegal reserved word"); + error(linecount,"Illegal reserved word"); } lextoken.t_string = ltext; return C_IDENT; @@ -245,7 +245,7 @@ skipcomment(flag) { int saved; /* line count on which comment starts */ saved = linecount; - if (input() != '*') error(linecount,"illegal comment"); + if (input() != '*') error(linecount,"Illegal comment"); do { ch = input(); while (ch == '*') { -- 2.34.1