Fixed problem with parameter counts
This commit is contained in:
parent
86e38c87fb
commit
b10eadb10e
2 changed files with 18 additions and 13 deletions
|
@ -462,9 +462,9 @@ elem (register p_gram pres;)
|
||||||
C_IDENT { pe = search(UNKNOWN,lextoken.t_string,BOTH);
|
C_IDENT { pe = search(UNKNOWN,lextoken.t_string,BOTH);
|
||||||
*pres = *pe;
|
*pres = *pe;
|
||||||
}
|
}
|
||||||
[ params { if (nparams > 14) {
|
[ params { if (nparams > 15) {
|
||||||
error(linecount,"Too many parameters");
|
error(linecount,"Too many parameters");
|
||||||
} else g_setnpar(pres,nparams+1);
|
} else g_setnpar(pres,nparams);
|
||||||
if (g_gettype(pres) == TERMINAL) {
|
if (g_gettype(pres) == TERMINAL) {
|
||||||
error(linecount,
|
error(linecount,
|
||||||
"Terminal with parameters");
|
"Terminal with parameters");
|
||||||
|
@ -543,7 +543,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
|
||||||
* is ch2.
|
* is ch2.
|
||||||
* If flag != 0, copy opening and closing parameters too.
|
* If flag != 0, copy opening and closing parameters too.
|
||||||
*/
|
*/
|
||||||
static int id_seen = 0;
|
static int text_seen = 0;
|
||||||
register FILE *f;
|
register FILE *f;
|
||||||
register ch; /* Current char */
|
register ch; /* Current char */
|
||||||
register match; /* used to read strings */
|
register match; /* used to read strings */
|
||||||
|
@ -552,7 +552,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
|
||||||
f = fact;
|
f = fact;
|
||||||
if (!level) {
|
if (!level) {
|
||||||
saved = linecount;
|
saved = linecount;
|
||||||
id_seen = 0;
|
text_seen = 0;
|
||||||
nparams = 0; /* count comma's */
|
nparams = 0; /* count comma's */
|
||||||
putc('\0',f);
|
putc('\0',f);
|
||||||
fprintf(f,"# line %d \"%s\"\n", linecount,f_input);
|
fprintf(f,"# line %d \"%s\"\n", linecount,f_input);
|
||||||
|
@ -560,11 +560,12 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
|
||||||
if (level || flag) putc(ch1,f);
|
if (level || flag) putc(ch1,f);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ch = input();
|
ch = input();
|
||||||
if (c_class[ch] == ISLET) id_seen = 1;
|
|
||||||
if (ch == ch2) {
|
if (ch == ch2) {
|
||||||
if (!level) unput(ch);
|
if (!level) {
|
||||||
|
unput(ch);
|
||||||
|
if (text_seen) nparams++;
|
||||||
|
}
|
||||||
if (level || flag) putc(ch,f);
|
if (level || flag) putc(ch,f);
|
||||||
if (id_seen) nparams++;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
|
@ -574,12 +575,15 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
|
||||||
error(linecount,"Parentheses mismatch");
|
error(linecount,"Parentheses mismatch");
|
||||||
break;
|
break;
|
||||||
case '(':
|
case '(':
|
||||||
|
text_seen = 1;
|
||||||
copyact('(',')',flag,level+1);
|
copyact('(',')',flag,level+1);
|
||||||
continue;
|
continue;
|
||||||
case '{':
|
case '{':
|
||||||
|
text_seen = 1;
|
||||||
copyact('{','}',flag,level+1);
|
copyact('{','}',flag,level+1);
|
||||||
continue;
|
continue;
|
||||||
case '[':
|
case '[':
|
||||||
|
text_seen = 1;
|
||||||
copyact('[',']',flag,level+1);
|
copyact('[',']',flag,level+1);
|
||||||
continue;
|
continue;
|
||||||
case '/':
|
case '/':
|
||||||
|
@ -591,15 +595,13 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ch = '/';
|
ch = '/';
|
||||||
|
text_seen = 1;
|
||||||
break;
|
break;
|
||||||
case ';':
|
case ';':
|
||||||
case ',':
|
case ',':
|
||||||
if (!level) { /*
|
if (! level && text_seen) {
|
||||||
* Only ','s and ';'s on the
|
text_seen = 0;
|
||||||
* outer level are counted
|
|
||||||
*/
|
|
||||||
nparams++;
|
nparams++;
|
||||||
id_seen = 0;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\'':
|
case '\'':
|
||||||
|
@ -608,6 +610,7 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
|
||||||
* watch out for brackets in strings, they do not
|
* watch out for brackets in strings, they do not
|
||||||
* count !
|
* count !
|
||||||
*/
|
*/
|
||||||
|
text_seen = 1;
|
||||||
match = ch;
|
match = ch;
|
||||||
putc(ch,f);
|
putc(ch,f);
|
||||||
while((ch = input())) {
|
while((ch = input())) {
|
||||||
|
@ -627,6 +630,8 @@ copyact(ch1,ch2,flag,level) char ch1,ch2; {
|
||||||
case EOF :
|
case EOF :
|
||||||
if (!level) error(saved,"Action does not terminate");
|
if (!level) error(saved,"Action does not terminate");
|
||||||
return;
|
return;
|
||||||
|
default:
|
||||||
|
if (c_class[ch] != ISSPA) text_seen = 1;
|
||||||
}
|
}
|
||||||
putc(ch,f);
|
putc(ch,f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ check(p) register p_gram p; {
|
||||||
n = &nonterms[g_getcont(p)];
|
n = &nonterms[g_getcont(p)];
|
||||||
if (g_getnpar(p) != getntparams(n)) {
|
if (g_getnpar(p) != getntparams(n)) {
|
||||||
error(p->g_lineno,
|
error(p->g_lineno,
|
||||||
"Call of %s : parameter count mismatch",
|
"Call of %s: parameter count mismatch",
|
||||||
n->n_name);
|
n->n_name);
|
||||||
}
|
}
|
||||||
break; }
|
break; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue