Added a flag to not give warnings
This commit is contained in:
parent
896fec3fc5
commit
db572116e1
|
@ -85,6 +85,12 @@ the sets that are computed are extended with the nonterminal
|
||||||
symbols and these extended sets are also included in the
|
symbols and these extended sets are also included in the
|
||||||
\fILL.output\fP
|
\fILL.output\fP
|
||||||
file.
|
file.
|
||||||
|
.PP
|
||||||
|
If the
|
||||||
|
\fB\-w\fP
|
||||||
|
or the
|
||||||
|
\fB\-W\fP
|
||||||
|
flag is given, no warnings are given.
|
||||||
.SH FILES
|
.SH FILES
|
||||||
LL.output verbose output file
|
LL.output verbose output file
|
||||||
.br
|
.br
|
||||||
|
|
|
@ -487,7 +487,7 @@ do_lengthcomp() {
|
||||||
* nonterminal.
|
* nonterminal.
|
||||||
* This length consists of two fields: the number of terminals,
|
* This length consists of two fields: the number of terminals,
|
||||||
* and a number that is composed of
|
* 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
|
* - a crude measure of the number of terms and nonterminals in the
|
||||||
* production of this shortest string.
|
* production of this shortest string.
|
||||||
*/
|
*/
|
||||||
|
@ -521,6 +521,7 @@ complength(p,le) register p_gram p; p_length le; {
|
||||||
register p_term q;
|
register p_term q;
|
||||||
t_length i;
|
t_length i;
|
||||||
t_length X;
|
t_length X;
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
X.cnt = 0;
|
X.cnt = 0;
|
||||||
X.val = 0;
|
X.val = 0;
|
||||||
|
@ -528,16 +529,17 @@ complength(p,le) register p_gram p; p_length le; {
|
||||||
switch (g_gettype(p)) {
|
switch (g_gettype(p)) {
|
||||||
case LITERAL :
|
case LITERAL :
|
||||||
case TERMINAL :
|
case TERMINAL :
|
||||||
if (!X.cnt) add(&X, 1, g_getcont(p));
|
add(&X, 1, 0);
|
||||||
else add(&X, 1, 0);
|
|
||||||
break;
|
break;
|
||||||
case ALTERNATION :
|
case ALTERNATION :
|
||||||
|
|
||||||
X.cnt = INFINITY;
|
X.cnt = INFINITY;
|
||||||
X.val = INFINITY;
|
X.val = INFINITY;
|
||||||
while (g_gettype(p) != EORULE) {
|
while (g_gettype(p) != EORULE) {
|
||||||
|
cnt++;
|
||||||
l = g_getlink(p);
|
l = g_getlink(p);
|
||||||
complength(l->l_rule,&i);
|
complength(l->l_rule,&i);
|
||||||
|
i.val += cnt;
|
||||||
if (l->l_flag & DEF) {
|
if (l->l_flag & DEF) {
|
||||||
X = i;
|
X = i;
|
||||||
break;
|
break;
|
||||||
|
@ -557,11 +559,11 @@ complength(p,le) register p_gram p; p_length le; {
|
||||||
|
|
||||||
q = g_getterm(p);
|
q = g_getterm(p);
|
||||||
rep = r_getkind(q);
|
rep = r_getkind(q);
|
||||||
|
X.val += 1;
|
||||||
if ((q->t_flags&PERSISTENT) ||
|
if ((q->t_flags&PERSISTENT) ||
|
||||||
rep==FIXED || rep==PLUS) {
|
rep==FIXED || rep==PLUS) {
|
||||||
complength(q->t_rule,&i);
|
complength(q->t_rule,&i);
|
||||||
add(&X, i.cnt, i.val);
|
add(&X, i.cnt, i.val);
|
||||||
if (i.cnt == 0) X.val += ntokens;
|
|
||||||
if (rep == FIXED && r_getnum(q) > 0) {
|
if (rep == FIXED && r_getnum(q) > 0) {
|
||||||
for (rep = r_getnum(q) - 1;
|
for (rep = r_getnum(q) - 1;
|
||||||
rep > 0; rep--) {
|
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; }
|
break; }
|
||||||
case NONTERM : {
|
case NONTERM : {
|
||||||
int nn = g_getcont(p);
|
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;
|
else if (x == -1) x = INFINITY;
|
||||||
add(&X, x, pl->val);
|
add(&X, x, pl->val);
|
||||||
if (x == 0) {
|
X.val += 1;
|
||||||
/* Empty producing nonterminal */
|
}
|
||||||
X.val += ntokens;
|
|
||||||
}}
|
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
@ -602,7 +598,7 @@ add(a, c, v) register p_length a; {
|
||||||
a->cnt = INFINITY;
|
a->cnt = INFINITY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (a->cnt == 0) a->val = v;
|
a->val += v;
|
||||||
a->cnt += c;
|
a->cnt += c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,15 +619,17 @@ setdefaults(p) register p_gram p; {
|
||||||
break;
|
break;
|
||||||
case ALTERNATION: {
|
case ALTERNATION: {
|
||||||
register p_link l, l1;
|
register p_link l, l1;
|
||||||
int temp = 0, temp1;
|
int temp = 0, temp1, cnt = 0;
|
||||||
t_length count, i;
|
t_length count, i;
|
||||||
|
|
||||||
count.cnt = INFINITY;
|
count.cnt = INFINITY;
|
||||||
count.val = INFINITY;
|
count.val = INFINITY;
|
||||||
l1 = g_getlink(p);
|
l1 = g_getlink(p);
|
||||||
do {
|
do {
|
||||||
|
cnt++;
|
||||||
l = g_getlink(p);
|
l = g_getlink(p);
|
||||||
complength(l->l_rule,&i);
|
complength(l->l_rule,&i);
|
||||||
|
i.val += cnt;
|
||||||
if (l->l_flag & DEF) temp = 1;
|
if (l->l_flag & DEF) temp = 1;
|
||||||
temp1 = compare(&i, &count);
|
temp1 = compare(&i, &count);
|
||||||
if (temp1 < 0 ||
|
if (temp1 < 0 ||
|
||||||
|
|
|
@ -53,6 +53,7 @@ extern struct order *sorder, *porder;
|
||||||
*/
|
*/
|
||||||
extern string e_noopen; /* Error message string used often */
|
extern string e_noopen; /* Error message string used often */
|
||||||
extern int verbose; /* Level of verbosity */
|
extern int verbose; /* Level of verbosity */
|
||||||
|
extern int wflag; /* warnings? */
|
||||||
extern string lexical; /* name of lexical analyser */
|
extern string lexical; /* name of lexical analyser */
|
||||||
extern string onerror; /* name of user error handler */
|
extern string onerror; /* name of user error handler */
|
||||||
extern int ntneeded; /* ntneeded = 1 if nonterminals are included
|
extern int ntneeded; /* ntneeded = 1 if nonterminals are included
|
||||||
|
|
|
@ -47,6 +47,7 @@ string f_temp = ACTFILE;
|
||||||
string f_input;
|
string f_input;
|
||||||
string e_noopen = "Cannot open %s";
|
string e_noopen = "Cannot open %s";
|
||||||
int verbose;
|
int verbose;
|
||||||
|
int wflag;
|
||||||
string lexical;
|
string lexical;
|
||||||
string onerror;
|
string onerror;
|
||||||
int ntneeded;
|
int ntneeded;
|
||||||
|
|
|
@ -52,6 +52,10 @@ main(argc,argv) register string argv[]; {
|
||||||
while (argc >= 2 && (arg = argv[1], *arg == '-')) {
|
while (argc >= 2 && (arg = argv[1], *arg == '-')) {
|
||||||
while (*++arg) {
|
while (*++arg) {
|
||||||
switch(*arg) {
|
switch(*arg) {
|
||||||
|
case 'w':
|
||||||
|
case 'W':
|
||||||
|
wflag = 1;
|
||||||
|
continue;
|
||||||
case 'v':
|
case 'v':
|
||||||
case 'V':
|
case 'V':
|
||||||
verbose++;
|
verbose++;
|
||||||
|
@ -221,6 +225,7 @@ warning(lineno,s,t,u) string s,t,u; {
|
||||||
* Just a warning
|
* Just a warning
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (wflag) return;
|
||||||
if (!lineno) lineno = 1;
|
if (!lineno) lineno = 1;
|
||||||
fprintf(stderr,"\"%s\", line %d : (Warning) ",f_input, lineno);
|
fprintf(stderr,"\"%s\", line %d : (Warning) ",f_input, lineno);
|
||||||
fprintf(stderr,s,t,u);
|
fprintf(stderr,s,t,u);
|
||||||
|
|
Loading…
Reference in a new issue