[comp.unix.wizards] Lex/Yacc bug

dave@sq.UUCP (05/13/87)

Is this a bug in lex?

	On the AT&T 3B2 Sys V and Sun 3/180 Sun Unix 3.0
and lex being used with yacc. Lex busts when used with a token
defined in yacc as "p" "m" or "c".

For example cut up the following.

********* yacc file (foo) **********
%token p
%%
null	:
	;
%%
#include "lex.yy.c"

main()
{
	yyparse();
}
********** lex file (bar)************
%%
********** type the following *******
yacc foo
lex bar
cc -o blah y.tab.c -ll
*****you should get something like***
"./lex.yy.c", line 232: syntax error at or near constant 257
"./lex.yy.c", line 233: syntax error at or near constant 257
"./lex.yy.c", line 236: illegal indirection
"./lex.yy.c", line 238: illegal lhs of assignment operator
"./lex.yy.c", line 238: illegal indirection
********** offensive code follows ***
********** from /usr/lib/lex/ncform *
yyback(p, m)
	int *p;
{
if (p==0) return(0);
while (*p)
	{
	if (*p++ == m)
		return(1);
	}
return(0);
}
	/* the following are only used in the lex library */
yyinput(){
	return(input());
	}
yyoutput(c)
  int c; {
	output(c);
	}
yyunput(c)
   int c; {
	unput(c);
	}
*********
Shouldn't these declarations use obscure variable names like yym yyp yyc ?


						David R. Seaman
------
{utai,utzoo}!sq!dave                   ssssss
                                      s      s
SoftQuad Inc. (home of sqtroff)       sss    s
720 Spadina Ave                       s  s   s
Toronto, Ontario, Canada              s  s   s
(416) 963-8337                         ssssss 
                                         s
                                          ssq