Added a flag to not give warnings

This commit is contained in:
ceriel 1987-11-27 11:04:07 +00:00
parent 896fec3fc5
commit db572116e1
5 changed files with 25 additions and 14 deletions

View file

@ -85,6 +85,12 @@ the sets that are computed are extended with the nonterminal
symbols and these extended sets are also included in the
\fILL.output\fP
file.
.PP
If the
\fB\-w\fP
or the
\fB\-W\fP
flag is given, no warnings are given.
.SH FILES
LL.output verbose output file
.br

View file

@ -487,7 +487,7 @@ do_lengthcomp() {
* nonterminal.
* This length consists of two fields: the number of terminals,
* and a number that is composed of
* - the value of the first terminal
* - the number of this alternative
* - a crude measure of the number of terms and nonterminals in the
* production of this shortest string.
*/
@ -521,6 +521,7 @@ complength(p,le) register p_gram p; p_length le; {
register p_term q;
t_length i;
t_length X;
int cnt = 0;
X.cnt = 0;
X.val = 0;
@ -528,16 +529,17 @@ complength(p,le) register p_gram p; p_length le; {
switch (g_gettype(p)) {
case LITERAL :
case TERMINAL :
if (!X.cnt) add(&X, 1, g_getcont(p));
else add(&X, 1, 0);
add(&X, 1, 0);
break;
case ALTERNATION :
X.cnt = INFINITY;
X.val = INFINITY;
while (g_gettype(p) != EORULE) {
cnt++;
l = g_getlink(p);
complength(l->l_rule,&i);
i.val += cnt;
if (l->l_flag & DEF) {
X = i;
break;
@ -557,11 +559,11 @@ complength(p,le) register p_gram p; p_length le; {
q = g_getterm(p);
rep = r_getkind(q);
X.val += 1;
if ((q->t_flags&PERSISTENT) ||
rep==FIXED || rep==PLUS) {
complength(q->t_rule,&i);
add(&X, i.cnt, i.val);
if (i.cnt == 0) X.val += ntokens;
if (rep == FIXED && r_getnum(q) > 0) {
for (rep = r_getnum(q) - 1;
rep > 0; rep--) {
@ -569,10 +571,6 @@ complength(p,le) register p_gram p; p_length le; {
}
}
}
else {
/* Empty producing term on this path */
X.val += ntokens;
}
break; }
case NONTERM : {
int nn = g_getcont(p);
@ -586,10 +584,8 @@ complength(p,le) register p_gram p; p_length le; {
}
else if (x == -1) x = INFINITY;
add(&X, x, pl->val);
if (x == 0) {
/* Empty producing nonterminal */
X.val += ntokens;
}}
X.val += 1;
}
}
p++;
}
@ -602,7 +598,7 @@ add(a, c, v) register p_length a; {
a->cnt = INFINITY;
return;
}
if (a->cnt == 0) a->val = v;
a->val += v;
a->cnt += c;
}
@ -623,15 +619,17 @@ setdefaults(p) register p_gram p; {
break;
case ALTERNATION: {
register p_link l, l1;
int temp = 0, temp1;
int temp = 0, temp1, cnt = 0;
t_length count, i;
count.cnt = INFINITY;
count.val = INFINITY;
l1 = g_getlink(p);
do {
cnt++;
l = g_getlink(p);
complength(l->l_rule,&i);
i.val += cnt;
if (l->l_flag & DEF) temp = 1;
temp1 = compare(&i, &count);
if (temp1 < 0 ||

View file

@ -53,6 +53,7 @@ extern struct order *sorder, *porder;
*/
extern string e_noopen; /* Error message string used often */
extern int verbose; /* Level of verbosity */
extern int wflag; /* warnings? */
extern string lexical; /* name of lexical analyser */
extern string onerror; /* name of user error handler */
extern int ntneeded; /* ntneeded = 1 if nonterminals are included

View file

@ -47,6 +47,7 @@ string f_temp = ACTFILE;
string f_input;
string e_noopen = "Cannot open %s";
int verbose;
int wflag;
string lexical;
string onerror;
int ntneeded;

View file

@ -52,6 +52,10 @@ main(argc,argv) register string argv[]; {
while (argc >= 2 && (arg = argv[1], *arg == '-')) {
while (*++arg) {
switch(*arg) {
case 'w':
case 'W':
wflag = 1;
continue;
case 'v':
case 'V':
verbose++;
@ -221,6 +225,7 @@ warning(lineno,s,t,u) string s,t,u; {
* Just a warning
*/
if (wflag) return;
if (!lineno) lineno = 1;
fprintf(stderr,"\"%s\", line %d : (Warning) ",f_input, lineno);
fprintf(stderr,s,t,u);