Next batch, LLgen no longuer have warning under linux/clang.

This commit is contained in:
Manoel Trapier 2013-03-07 18:13:58 +01:00 committed by Manoël Trapier
parent d28368333a
commit f1cd17c51e
8 changed files with 103 additions and 189 deletions

View File

@ -84,13 +84,7 @@ extern LLnc_recover();
# include "assert.h" # include "assert.h"
# include "cclass.h" # include "cclass.h"
# ifndef NORCSID #include "LLgen.h"
static string rcsid = "$Id$";
# endif
p_mem alloc(), ralloc();
string store();
p_gram search();
long ftell();
static int acount; /* count #of global actions */ static int acount; /* count #of global actions */
static p_term t_list; static p_term t_list;
@ -106,15 +100,9 @@ static int max_rules;
#define RULEINCR 32 #define RULEINCR 32
/* Here are defined : */ /* Here are defined : */
STATIC newnorder();
STATIC newtorder();
STATIC mkalt();
STATIC mkterm();
STATIC p_gram copyrule();
/* and of course LLparse() */ /* and of course LLparse() */
STATIC STATIC void newnorder(int index) {
newnorder(index) {
static int porder; static int porder;
if (norder != -1) { if (norder != -1) {
@ -125,8 +113,7 @@ newnorder(index) {
nonterms[porder].n_next = -1; nonterms[porder].n_next = -1;
} }
STATIC STATIC void newtorder(int index) {
newtorder(index) {
static int porder; static int porder;
if (torder != -1) { if (torder != -1) {
@ -137,7 +124,7 @@ newtorder(index) {
tokens[porder].t_next = -1; tokens[porder].t_next = -1;
} }
p_init() void p_init()
{ {
alt_table = (p_gram )alloc(ALTINCR*sizeof(t_gram)); alt_table = (p_gram )alloc(ALTINCR*sizeof(t_gram));
n_alts = 0; n_alts = 0;
@ -295,9 +282,9 @@ LL_NOSCANDONE(C_IDENT);
ff->ff_name = p; ff->ff_name = p;
ff->ff_next = start; ff->ff_next = start;
start = ff; start = ff;
while (ff = ff->ff_next) { while ((ff = ff->ff_next)) {
if (! strcmp(p, ff->ff_name)) { if (! strcmp(p, ff->ff_name)) {
error(linecount, "\"%s\" already used in a %%start", p); error(linecount, "\"%s\" already used in a %%start", p, NULL);
break; break;
} }
} }
@ -313,7 +300,7 @@ LL_NOSCANDONE(C_IDENT);
{ if (!lexical) { { if (!lexical) {
lexical = store(lextoken.t_string); lexical = store(lextoken.t_string);
} }
else error(linecount,"Duplicate %%lexical"); else error(linecount,"Duplicate %%lexical", NULL, NULL);
} }
LLtdecr(24); LLtdecr(24);
LL_NOSCANDONE(';'); LL_NOSCANDONE(';');
@ -327,11 +314,11 @@ LL_NOSCANDONE(C_IDENT);
prefix = store(lextoken.t_string); prefix = store(lextoken.t_string);
if (strlen(prefix) > 6) { if (strlen(prefix) > 6) {
error(linecount, error(linecount,
"%%prefix too long"); "%%prefix too long", NULL, NULL);
prefix[6] = 0; prefix[6] = 0;
} }
} }
else error(linecount,"Duplicate %%prefix"); else error(linecount,"Duplicate %%prefix", NULL, NULL);
} }
LLtdecr(24); LLtdecr(24);
LL_NOSCANDONE(';'); LL_NOSCANDONE(';');
@ -344,14 +331,14 @@ LL_NOSCANDONE(C_IDENT);
{ {
#ifdef NON_CORRECTING #ifdef NON_CORRECTING
if (non_corr) { if (non_corr) {
warning(linecount, "%%onerror conflicts with -n option"); warning(linecount, "%%onerror conflicts with -n option", NULL, NULL);
} }
else else
#endif #endif
if (! onerror) { if (! onerror) {
onerror = store(lextoken.t_string); onerror = store(lextoken.t_string);
} }
else error(linecount,"Duplicate %%onerror"); else error(linecount,"Duplicate %%onerror", NULL, NULL);
} }
LLtdecr(24); LLtdecr(24);
LL_NOSCANDONE(';'); LL_NOSCANDONE(';');
@ -407,7 +394,7 @@ LL_SAFE(C_IDENT);
p = &nonterms[g_getcont(temp)]; p = &nonterms[g_getcont(temp)];
if (p->n_rule) { if (p->n_rule) {
error(linecount, error(linecount,
"Nonterminal %s already defined", lextoken.t_string); "Nonterminal %s already defined", lextoken.t_string, NULL);
} }
/* /*
* Remember the order in which the nonterminals * Remember the order in which the nonterminals
@ -441,7 +428,7 @@ LL_SAFE(C_PARAMS);
{ if (lextoken.t_num > 0) { { if (lextoken.t_num > 0) {
p->n_flags |= PARAMS; p->n_flags |= PARAMS;
if (lextoken.t_num > 15) { if (lextoken.t_num > 15) {
error(linecount,"Too many parameters"); error(linecount,"Too many parameters", NULL, NULL);
} }
else setntparams(p,lextoken.t_num); else setntparams(p,lextoken.t_num);
} }
@ -538,7 +525,7 @@ LL6_simpleproduction(
if (t & DEF) { if (t & DEF) {
if (haddefault) { if (haddefault) {
error(n_lc, error(n_lc,
"More than one %%default in alternation"); "More than one %%default in alternation", NULL, NULL);
} }
haddefault = 1; haddefault = 1;
} }
@ -569,7 +556,7 @@ break;
# line 282 "LLgen.g" # line 282 "LLgen.g"
{ if (conflres & (COND|PREFERING|AVOIDING)) { { if (conflres & (COND|PREFERING|AVOIDING)) {
error(n_lc, error(n_lc,
"Resolver on last alternative not allowed"); "Resolver on last alternative not allowed", NULL, NULL);
} }
mkalt(*p,conflres,n_lc,&alt_table[n_alts++]); mkalt(*p,conflres,n_lc,&alt_table[n_alts++]);
altcnt++; altcnt++;
@ -585,7 +572,7 @@ LLtdecr(26);
# line 292 "LLgen.g" # line 292 "LLgen.g"
{ if (conflres & (COND|PREFERING|AVOIDING)) { { if (conflres & (COND|PREFERING|AVOIDING)) {
error(o_lc, error(o_lc,
"No alternation conflict resolver allowed here"); "No alternation conflict resolver allowed here", NULL, NULL);
} }
/* /*
if (conflres & DEF) { if (conflres & DEF) {
@ -604,8 +591,7 @@ goto L_3;
# line 306 "LLgen.g" # line 306 "LLgen.g"
STATIC STATIC void mkalt(p_gram prod, int condition, int lc, p_gram res) {
mkalt(prod,condition,lc,res) p_gram prod; register p_gram res; {
/* /*
* Create an alternation and initialise it. * Create an alternation and initialise it.
*/ */
@ -759,7 +745,7 @@ LL_SAFE(C_ILLEGAL);
rule_table[n_rules++] = rule_table[n_rules++] =
*search(TERMINAL, "LLILLEGAL", BOTH); *search(TERMINAL, "LLILLEGAL", BOTH);
if (*conflres & DEF) { if (*conflres & DEF) {
error(linecount, "%%illegal not allowed in %%default rule"); error(linecount, "%%illegal not allowed in %%default rule", NULL, NULL);
} }
#endif #endif
} }
@ -877,7 +863,7 @@ goto L_10;
if ((q->t_flags & RESOLVER) && if ((q->t_flags & RESOLVER) &&
(kind == PLUS || kind == FIXED)) { (kind == PLUS || kind == FIXED)) {
error(linecount, error(linecount,
"%%while not allowed in this term"); "%%while not allowed in this term", NULL, NULL);
} }
/* /*
* A persistent fixed term is the same * A persistent fixed term is the same
@ -921,8 +907,7 @@ break;
# line 454 "LLgen.g" # line 454 "LLgen.g"
STATIC STATIC void mkterm(p_gram prod, int flags, int lc, p_gram result) {
mkterm(prod,flags,lc,result) p_gram prod; register p_gram result; {
/* /*
* Create a term, initialise it and return * Create a term, initialise it and return
* a grammar element containing it * a grammar element containing it
@ -1086,7 +1071,7 @@ LL_SSCANDONE(C_IDENT);
if (erroneous) { if (erroneous) {
if (g_gettype(pres) != TERMINAL){ if (g_gettype(pres) != TERMINAL){
warning(linecount, warning(linecount,
"Erroneous only allowed on terminal"); "Erroneous only allowed on terminal", NULL, NULL);
erroneous = 0; erroneous = 0;
} }
else else
@ -1124,11 +1109,11 @@ LLtdecr(6);
LL_SAFE(C_PARAMS); LL_SAFE(C_PARAMS);
# line 522 "LLgen.g" # line 522 "LLgen.g"
{ if (lextoken.t_num > 15) { { if (lextoken.t_num > 15) {
error(linecount,"Too many parameters"); error(linecount,"Too many parameters", NULL, NULL);
} else g_setnpar(pres,lextoken.t_num); } else g_setnpar(pres,lextoken.t_num);
if (g_gettype(pres) == TERMINAL) { if (g_gettype(pres) == TERMINAL) {
error(linecount, error(linecount,
"Terminal with parameters"); "Terminal with parameters", NULL, NULL);
} }
} }
LLread(); LLread();
@ -1216,7 +1201,7 @@ LL_NOSCANDONE(C_IDENT);
ff = g_getsubparse(pres); ff = g_getsubparse(pres);
while (ff) { while (ff) {
if (ff->ff_nont == g_getcont(temp)) { if (ff->ff_nont == g_getcont(temp)) {
warning(linecount, "\"%s\" used twice in %%substart", lextoken.t_string); warning(linecount, "\"%s\" used twice in %%substart", lextoken.t_string, NULL);
break; break;
} }
ff = ff->ff_next; ff = ff->ff_next;
@ -1348,7 +1333,7 @@ LL_SAFE(C_NUMBER);
# line 621 "LLgen.g" # line 621 "LLgen.g"
{ *t = lextoken.t_num; { *t = lextoken.t_num;
if (*t <= 0 || *t >= 8192) { if (*t <= 0 || *t >= 8192) {
error(linecount,"Illegal number"); error(linecount,"Illegal number", NULL, NULL);
} }
} }
} }

View File

@ -26,13 +26,7 @@
# include "assert.h" # include "assert.h"
# include "cclass.h" # include "cclass.h"
# ifndef NORCSID #include "LLgen.h"
static string rcsid = "$Id$";
# endif
p_mem alloc(), ralloc();
string store();
p_gram search();
long ftell();
static int acount; /* count #of global actions */ static int acount; /* count #of global actions */
static p_term t_list; static p_term t_list;
@ -48,15 +42,9 @@ static int max_rules;
#define RULEINCR 32 #define RULEINCR 32
/* Here are defined : */ /* Here are defined : */
STATIC newnorder();
STATIC newtorder();
STATIC mkalt();
STATIC mkterm();
STATIC p_gram copyrule();
/* and of course LLparse() */ /* and of course LLparse() */
STATIC STATIC void newnorder(int index) {
newnorder(index) {
static int porder; static int porder;
if (norder != -1) { if (norder != -1) {
@ -67,8 +55,7 @@ newnorder(index) {
nonterms[porder].n_next = -1; nonterms[porder].n_next = -1;
} }
STATIC STATIC void newtorder(int index) {
newtorder(index) {
static int porder; static int porder;
if (torder != -1) { if (torder != -1) {
@ -79,7 +66,7 @@ newtorder(index) {
tokens[porder].t_next = -1; tokens[porder].t_next = -1;
} }
p_init() void p_init()
{ {
alt_table = (p_gram )alloc(ALTINCR*sizeof(t_gram)); alt_table = (p_gram )alloc(ALTINCR*sizeof(t_gram));
n_alts = 0; n_alts = 0;

View File

@ -92,7 +92,7 @@ void correct_prefix(void);
/* LLgen.c */ /* LLgen.c */
void newnorder(int index); void newnorder(int index);
void newtorder(int index); void newtorder(int index);
int p_init(void); void p_init(void);
void LL0_spec(void); void LL0_spec(void);
void mkalt(p_gram prod, int condition, int lc, p_gram res); void mkalt(p_gram prod, int condition, int lc, p_gram res);
void mkterm(p_gram prod, int flags, int lc, p_gram result); void mkterm(p_gram prod, int flags, int lc, p_gram result);
@ -126,7 +126,7 @@ void copyfile(char *file);
void install(char *target, char *source); void install(char *target, char *source);
/* name.c */ /* name.c */
int name_init(void); void name_init(void);
p_entry newentry(char * str, p_entry next); p_entry newentry(char * str, p_entry next);
char * store(char * s); char * store(char * s);
int hash(char * str); int hash(char * str);
@ -138,24 +138,24 @@ void reachable(p_nont p);
void reachwalk(p_gram p); void reachwalk(p_gram p);
/* sets.c */ /* sets.c */
int setinit(int nt_needed); void setinit(int nt_needed);
p_set get_set(void); p_set get_set(void);
p_set setalloc(void); p_set setalloc(void);
int setunion(p_set a, p_set b); int setunion(p_set a, p_set b);
int setintersect(p_set a, p_set b); int setintersect(p_set a, p_set b);
int setminus(p_set a, p_set b); void setminus(p_set a, p_set b);
int setempty(p_set p); int setempty(p_set p);
int findindex(p_set set); int findindex(p_set set);
int setcount(p_set set, int *saved); int setcount(p_set set, int *saved);
/* tokens.c */ /* tokens.c */
void copyact(int ch1, int ch2, int flag, int level); void copyact(char ch1, char ch2, int flag, int level);
int scanner(void); int scanner(void);
int input(void); int input(void);
int unput(int c); void unput(int c);
int skipcomment(int flag); void skipcomment(int flag);
char * vallookup(int s); char * vallookup(int s);
char * cpy(int s, char * p, int inserted); char * cpy(int s, char * p, int inserted);
int LLmessage(int d); void LLmessage(int d);
#endif /* LLGEN_H */ #endif /* LLGEN_H */

View File

@ -17,6 +17,9 @@
* initialising routine. * initialising routine.
*/ */
#include <stdlib.h>
#include <string.h>
# include "types.h" # include "types.h"
# include "extern.h" # include "extern.h"
# include "assert.h" # include "assert.h"
@ -125,19 +128,19 @@ search(type,str,option) register string str; {
if (type == TERMINAL) { if (type == TERMINAL) {
error(linecount, error(linecount,
"%s: is already a nonterminal", "%s: is already a nonterminal",
str); str, NULL);
continue; continue;
} }
else if (type == NONTERM) { else if (type == NONTERM) {
error(linecount, error(linecount,
"%s : is already a token", "%s : is already a token",
str); str, NULL);
continue; continue;
} }
} }
if (option==ENTERING) { if (option==ENTERING) {
error(linecount, error(linecount,
"%s : is already defined",str); "%s : is already defined",str, NULL);
} }
p->h_type.g_lineno = linecount; p->h_type.g_lineno = linecount;
return &(p->h_type); return &(p->h_type);
@ -180,7 +183,7 @@ search(type,str,option) register string str; {
val = '\\'; val = '\\';
break; break;
default : default :
error(linecount,e_literal); error(linecount,e_literal, NULL, NULL);
} }
} else { } else {
/* /*
@ -189,7 +192,7 @@ search(type,str,option) register string str; {
if (str[1] > '3' || str[1] < '0' || if (str[1] > '3' || str[1] < '0' ||
str[2] > '7' || str[2] < '0' || str[2] > '7' || str[2] < '0' ||
str[3] > '7' || str[3] < '0' || str[3] > '7' || str[3] < '0' ||
str[4] != '\0') error(linecount,e_literal); str[4] != '\0') error(linecount,e_literal, NULL, NULL);
val = 64*str[1] - 73*'0' + val = 64*str[1] - 73*'0' +
8*str[2] + str[3]; 8*str[2] + str[3];
} }
@ -198,7 +201,7 @@ search(type,str,option) register string str; {
* No escape in literal * No escape in literal
*/ */
if (str[1] == '\0') val = str[0]; if (str[1] == '\0') val = str[0];
else error(linecount,e_literal); else error(linecount,e_literal, NULL, NULL);
} }
pt->t_tokno = val; pt->t_tokno = val;
g_settype(&(p->h_type), LITERAL); g_settype(&(p->h_type), LITERAL);

View File

@ -32,17 +32,15 @@
# include "assert.h" # include "assert.h"
# include "sets.h" # include "sets.h"
#include "LLgen.h"
#define LLALT 9999 #define LLALT 9999
static int nt_highest; static int nt_highest;
extern int nbytes; extern int nbytes;
extern p_mem alloc();
extern p_set start_firsts;
extern p_set setalloc();
extern p_gram search();
STATIC save_rule(); STATIC void save_rule(p_gram p, int tail);
STATIC save_set(); STATIC void save_set(p_set p);
/* t_list will contain terms to be `flattened' */ /* t_list will contain terms to be `flattened' */
static struct t_list { static struct t_list {
@ -69,7 +67,7 @@ static FILE *fgram;
used when LLgen called with -n -s options */ used when LLgen called with -n -s options */
int act_nt; int act_nt;
save_grammar(f) FILE *f; { void save_grammar(FILE *f) {
/* /*
* Save the grammar * Save the grammar
*/ */
@ -131,7 +129,7 @@ save_grammar(f) FILE *f; {
if (! p->n_rule) { /* undefined */ if (! p->n_rule) { /* undefined */
f_input = p->n_string; f_input = p->n_string;
error(p->n_lineno,"Nonterminal %s not defined", error(p->n_lineno,"Nonterminal %s not defined",
p->n_name); p->n_name, NULL);
} }
/* Save the first_set and follow set */ /* Save the first_set and follow set */
@ -244,7 +242,7 @@ save_grammar(f) FILE *f; {
if (check == 0) if (check == 0)
warning((sub_list + i)->sub_action->g_lineno, warning((sub_list + i)->sub_action->g_lineno,
"\"%s\" is not a startsymbol", "\"%s\" is not a startsymbol",
(&nonterms[ff->ff_nont])->n_name); (&nonterms[ff->ff_nont])->n_name, NULL);
} }
save_set(temp_set); save_set(temp_set);
save_set(temp_set); save_set(temp_set);
@ -267,8 +265,7 @@ save_grammar(f) FILE *f; {
fprintf(fgram, "#define LLNNONTERMINALS %d\n", nt_highest - assval + 1); fprintf(fgram, "#define LLNNONTERMINALS %d\n", nt_highest - assval + 1);
} }
STATIC STATIC void save_rule(p_gram p, int tail) {
save_rule(p, tail) register p_gram p; int tail; {
/* /*
Walk through rule p, saving it. The non-terminal tail is Walk through rule p, saving it. The non-terminal tail is
appended to the rule. It needs to be appended in this function appended to the rule. It needs to be appended in this function
@ -363,8 +360,7 @@ save_rule(p, tail) register p_gram p; int tail; {
} }
} }
STATIC STATIC void save_set(p_set p) {
save_set(p) p_set p; {
register int k; register int k;
register unsigned i; register unsigned i;
int j; int j;

View File

@ -16,34 +16,24 @@
* Set manipulation and allocation routines. * Set manipulation and allocation routines.
*/ */
#include <stdlib.h>
#include <stdio.h>
# include "types.h" # include "types.h"
# include "extern.h" # include "extern.h"
# include "sets.h" # include "sets.h"
# include "assert.h" # include "assert.h"
# ifndef NORCSID #include "LLgen.h"
static string rcsid9 = "$Id$";
# endif
/* In this file the following routines are defined: */ /* In this file the following routines are defined: */
extern setinit();
extern p_set setalloc();
extern p_set get_set();
extern int setunion();
extern int setintersect();
extern setminus();
extern int setempty();
extern int findindex();
extern int setcount();
int nbytes; int nbytes;
static int setsize; static int setsize;
int tsetsize; int tsetsize;
p_set *setptr, *maxptr; p_set *setptr, *maxptr;
static t_info set_info; static t_info set_info;
p_mem alloc();
setinit(nt_needed) { void setinit(int nt_needed) {
/* /*
* Initialises some variables needed for setcomputations * Initialises some variables needed for setcomputations
*/ */
@ -61,8 +51,7 @@ setinit(nt_needed) {
set_info.i_incr = 20; set_info.i_incr = 20;
} }
p_set p_set get_set() {
get_set() {
/* /*
* Allocate a set that cannot be freed * Allocate a set that cannot be freed
*/ */
@ -80,8 +69,7 @@ get_set() {
return p; return p;
} }
p_set p_set setalloc() {
setalloc() {
/* /*
* Allocate a set which can later be freed. * Allocate a set which can later be freed.
*/ */
@ -95,8 +83,7 @@ setalloc() {
return p; return p;
} }
int int setunion(p_set a, p_set b) {
setunion(a,b) register p_set a,b; {
/* /*
* a = a union b. * a = a union b.
* Return 1 if the set a changed * Return 1 if the set a changed
@ -115,8 +102,7 @@ setunion(a,b) register p_set a,b; {
return nsub; return nsub;
} }
int int setintersect(p_set a, p_set b) {
setintersect(a,b) register p_set a,b; {
/* /*
* a = a intersect b. * a = a intersect b.
* return 1 if the result is empty * return 1 if the result is empty
@ -132,7 +118,7 @@ setintersect(a,b) register p_set a,b; {
return nempty; return nempty;
} }
setminus(a,b) register p_set a,b; { void setminus(p_set a, p_set b) {
/* /*
* a = a setminus b * a = a setminus b
*/ */
@ -144,8 +130,7 @@ setminus(a,b) register p_set a,b; {
} while (--i); } while (--i);
} }
int int setempty(p_set p) {
setempty(p) register p_set p; {
/* /*
* Return 1 if the set p is empty * Return 1 if the set p is empty
*/ */
@ -158,8 +143,7 @@ setempty(p) register p_set p; {
return 1; return 1;
} }
int int findindex(p_set set) {
findindex(set) p_set set; {
/* /*
* The set "set" will serve as a recovery set. * The set "set" will serve as a recovery set.
* Search for it in the table. If not present, enter it. * Search for it in the table. If not present, enter it.
@ -204,8 +188,7 @@ findindex(set) p_set set; {
return nbytes * (maxptr++ - setptr); return nbytes * (maxptr++ - setptr);
} }
int int setcount(p_set set, int *saved) {
setcount(set, saved) register p_set set; int *saved; {
register int i, j; register int i, j;
for (j = 0, i = 0; i < ntokens; i++) { for (j = 0, i = 0; i < ntokens; i++) {

View File

@ -15,6 +15,9 @@
#define LL_assert(x) /* nothing */ #define LL_assert(x) /* nothing */
#endif #endif
#include <stdio.h>
#include <string.h>
extern int LLsymb; extern int LLsymb;
#define LL_SAFE(x) /* Nothing */ #define LL_SAFE(x) /* Nothing */
@ -83,23 +86,9 @@ extern LLnc_recover();
# include "assert.h" # include "assert.h"
# include "cclass.h" # include "cclass.h"
# ifndef NORCSID #include "LLgen.h"
static string rcsidc = "$Id$";
# endif
/* Here are defined : */ /* Here are defined : */
extern int scanner();
extern LLmessage();
extern int input();
extern unput();
extern skipcomment();
# ifdef LINE_DIRECTIVE
STATIC linedirective();
# endif
STATIC string cpy();
STATIC string vallookup();
STATIC copyact();
static int nparams; static int nparams;
# line 75 "tokens.g" # line 75 "tokens.g"
@ -144,8 +133,7 @@ static t_token savedtok; /* to save lextoken in case of an insertion */
static int nostartline; /* = 0 if at the start of a line */ static int nostartline; /* = 0 if at the start of a line */
# endif # endif
STATIC STATIC void copyact(char ch1, char ch2, int flag, int level) {
copyact(ch1,ch2,flag,level) char ch1,ch2; {
/* /*
* Copy an action to file f. Opening bracket is ch1, closing bracket * Copy an action to file f. Opening bracket is ch1, closing bracket
* is ch2. * is ch2.
@ -186,7 +174,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
case ')': case ')':
case '}': case '}':
case ']': case ']':
error(linecount,"Parentheses mismatch"); error(linecount,"Parentheses mismatch", NULL, NULL);
break; break;
case '(': case '(':
text_seen = 1; text_seen = 1;
@ -217,7 +205,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
text_seen = 0; text_seen = 0;
nparams++; nparams++;
if (ch == ',' && (flag & 2)) { if (ch == ',' && (flag & 2)) {
warning(linecount, "Parameters may not be separated with a ','"); warning(linecount, "Parameters may not be separated with a ','", NULL, NULL);
ch = ';'; ch = ';';
} }
} }
@ -238,7 +226,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
ch = input(); ch = input();
} }
if (ch == '\n') { if (ch == '\n') {
error(linecount,"Newline in string"); error(linecount,"Newline in string", NULL, NULL);
unput(match); unput(match);
} }
putc(ch,f); putc(ch,f);
@ -246,7 +234,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
if (ch == match) break; if (ch == match) break;
/* Fall through */ /* Fall through */
case EOF : case EOF :
if (!level) error(saved,"Action does not terminate"); if (!level) error(saved,"Action does not terminate", NULL, NULL);
strip_grammar = sav_strip; strip_grammar = sav_strip;
return; return;
default: default:
@ -256,7 +244,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
} }
} }
scanner() { int scanner() {
/* /*
* Lexical analyser, what else * Lexical analyser, what else
*/ */
@ -306,7 +294,7 @@ scanner() {
for (;;) { for (;;) {
ch = input(); ch = input();
if (ch == '\n' || ch == EOF) { if (ch == '\n' || ch == EOF) {
error(linecount,"Missing '"); error(linecount,"Missing '", NULL, NULL);
break; break;
} }
if (ch == '\'') break; if (ch == '\'') break;
@ -370,7 +358,7 @@ scanner() {
} }
w++; w++;
} }
error(linecount,"Illegal reserved word"); error(linecount,"Illegal reserved word", NULL, NULL);
} }
lextoken.t_string = ltext; lextoken.t_string = ltext;
return C_IDENT; return C_IDENT;
@ -381,13 +369,13 @@ scanner() {
static int backupc; /* for unput() */ static int backupc; /* for unput() */
static int nonline; /* = 1 if last char read was a newline */ static int nonline; /* = 1 if last char read was a newline */
input() { int input() {
/* /*
* Low level input routine, used by all other input routines * Low level input routine, used by all other input routines
*/ */
register c; register c;
if (c = backupc) { if ((c = backupc)) {
/* Last char was "unput()". Deliver it again /* Last char was "unput()". Deliver it again
*/ */
backupc = 0; backupc = 0;
@ -412,14 +400,14 @@ input() {
return c; return c;
} }
unput(c) { void unput(int c) {
/* /*
* "unread" c * "unread" c
*/ */
backupc = c; backupc = c;
} }
skipcomment(flag) { void skipcomment(int flag) {
/* /*
* Skip comment. If flag != 0, the comment is inside a fragment * Skip comment. If flag != 0, the comment is inside a fragment
* of C-code, so keep it. * of C-code, so keep it.
@ -428,7 +416,7 @@ skipcomment(flag) {
int saved; /* line count on which comment starts */ int saved; /* line count on which comment starts */
saved = linecount; saved = linecount;
if (input() != '*') error(linecount,"Illegal comment"); if (input() != '*') error(linecount,"Illegal comment", NULL, NULL);
if (flag) putc('*', fact); if (flag) putc('*', fact);
do { do {
ch = input(); ch = input();
@ -439,12 +427,11 @@ skipcomment(flag) {
if (ch == '/') return; if (ch == '/') return;
} }
} while (ch != EOF); } while (ch != EOF);
error(saved,"Comment does not terminate"); error(saved,"Comment does not terminate", NULL, NULL);
} }
# ifdef LINE_DIRECTIVE # ifdef LINE_DIRECTIVE
STATIC STATIC void linedirective() {
linedirective() {
/* /*
* Read a line directive * Read a line directive
*/ */
@ -461,7 +448,7 @@ linedirective() {
ch = input(); ch = input();
} while (ch != '\n' && c_class[ch] != ISDIG); } while (ch != '\n' && c_class[ch] != ISDIG);
if (ch == '\n') { if (ch == '\n') {
error(linecount,s_error); error(linecount, s_error, NULL, NULL);
return; return;
} }
i = 0; i = 0;
@ -476,7 +463,7 @@ linedirective() {
*c++ = ch = input(); *c++ = ch = input();
} while (ch != '"' && ch != '\n'); } while (ch != '"' && ch != '\n');
if (ch == '\n') { if (ch == '\n') {
error(linecount,s_error); error(linecount, s_error, NULL, NULL);
return; return;
} }
*--c = '\0'; *--c = '\0';
@ -492,8 +479,7 @@ linedirective() {
} }
# endif # endif
STATIC string STATIC string vallookup(int s) {
vallookup(s) {
/* /*
* Look up the keyword that has token number s * Look up the keyword that has token number s
*/ */
@ -506,8 +492,7 @@ vallookup(s) {
return 0; return 0;
} }
STATIC string STATIC string cpy(int s, char *p, int inserted) {
cpy(s,p,inserted) register string p; {
/* /*
* Create a piece of error message for token s and put it at p. * Create a piece of error message for token s and put it at p.
* inserted = 0 if the token s was deleted (in which case we have * inserted = 0 if the token s was deleted (in which case we have
@ -577,9 +562,7 @@ cpy(s,p,inserted) register string p; {
return p; return p;
} }
string strcpy(); void LLmessage(int d) {
LLmessage(d) {
/* /*
* d is either 0, in which case the current token has been deleted, * d is either 0, in which case the current token has been deleted,
* or non-zero, in which case it represents a token that is inserted * or non-zero, in which case it represents a token that is inserted
@ -621,7 +604,7 @@ LLmessage(d) {
#ifdef LLNONCORR #ifdef LLNONCORR
else else
#endif #endif
error(linecount, "%s", buf); error(linecount, "%s", buf, NULL);
/* Don't change this line to /* Don't change this line to
* error(linecount, buf). * error(linecount, buf).
* The string in "buf" might contain '%' ... * The string in "buf" might contain '%' ...

View File

@ -24,23 +24,6 @@
# include "assert.h" # include "assert.h"
# include "cclass.h" # include "cclass.h"
# ifndef NORCSID
static string rcsidc = "$Id$";
# endif
/* Here are defined : */
extern int scanner();
extern LLmessage();
extern int input();
extern unput();
extern skipcomment();
# ifdef LINE_DIRECTIVE
STATIC linedirective();
# endif
STATIC string cpy();
STATIC string vallookup();
STATIC copyact();
static int nparams; static int nparams;
} }
/* Classes */ /* Classes */
@ -114,8 +97,7 @@ static t_token savedtok; /* to save lextoken in case of an insertion */
static int nostartline; /* = 0 if at the start of a line */ static int nostartline; /* = 0 if at the start of a line */
# endif # endif
STATIC STATIC void copyact(char ch1, char ch2, int flag, int level) {
copyact(ch1,ch2,flag,level) char ch1,ch2; {
/* /*
* Copy an action to file f. Opening bracket is ch1, closing bracket * Copy an action to file f. Opening bracket is ch1, closing bracket
* is ch2. * is ch2.
@ -226,7 +208,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
} }
} }
scanner() { int scanner() {
/* /*
* Lexical analyser, what else * Lexical analyser, what else
*/ */
@ -351,11 +333,11 @@ scanner() {
static int backupc; /* for unput() */ static int backupc; /* for unput() */
static int nonline; /* = 1 if last char read was a newline */ static int nonline; /* = 1 if last char read was a newline */
input() { int input() {
/* /*
* Low level input routine, used by all other input routines * Low level input routine, used by all other input routines
*/ */
register c; int c;
if (c = backupc) { if (c = backupc) {
/* Last char was "unput()". Deliver it again /* Last char was "unput()". Deliver it again
@ -382,14 +364,14 @@ input() {
return c; return c;
} }
unput(c) { void unput(c) {
/* /*
* "unread" c * "unread" c
*/ */
backupc = c; backupc = c;
} }
skipcomment(flag) { void skipcomment(flag) {
/* /*
* Skip comment. If flag != 0, the comment is inside a fragment * Skip comment. If flag != 0, the comment is inside a fragment
* of C-code, so keep it. * of C-code, so keep it.
@ -413,8 +395,7 @@ skipcomment(flag) {
} }
# ifdef LINE_DIRECTIVE # ifdef LINE_DIRECTIVE
STATIC STATIC void linedirective() {
linedirective() {
/* /*
* Read a line directive * Read a line directive
*/ */
@ -462,8 +443,7 @@ linedirective() {
} }
# endif # endif
STATIC string STATIC string vallookup(s) {
vallookup(s) {
/* /*
* Look up the keyword that has token number s * Look up the keyword that has token number s
*/ */
@ -476,8 +456,7 @@ vallookup(s) {
return 0; return 0;
} }
STATIC string STATIC string cpy(int s,string p, int inserted) {
cpy(s,p,inserted) register string p; {
/* /*
* Create a piece of error message for token s and put it at p. * Create a piece of error message for token s and put it at p.
* inserted = 0 if the token s was deleted (in which case we have * inserted = 0 if the token s was deleted (in which case we have
@ -547,9 +526,7 @@ cpy(s,p,inserted) register string p; {
return p; return p;
} }
string strcpy(); void LLmessage(int d) {
LLmessage(d) {
/* /*
* d is either 0, in which case the current token has been deleted, * d is either 0, in which case the current token has been deleted,
* or non-zero, in which case it represents a token that is inserted * or non-zero, in which case it represents a token that is inserted