Article View: comp.bugs.misc
Article #76Lex/Yacc bug
From: dave
Date: Wed, 13 May 1987 05:40
Date: Wed, 13 May 1987 05:40
71 lines
2182 bytes
2182 bytes
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
Technical Details
Message-ID:
<1987May13.014036.21651@sq.uucp>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!utfyzx!sq!daveShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!utfyzx!sq!dave From: dave@sq.UUCP Newsgroups: comp.bugs.misc,comp.unix.wizards Subject: Lex/Yacc bug Message-ID: <1987May13.014036.21651@sq.uucp> Date: Wed, 13-May-87 01:40:36 EDT Article-I.D.: sq.1987May13.014036.21651 Posted: Wed May 13 01:40:36 1987 Date-Received: Fri, 15-May-87 05:38:23 EDT Reply-To: dave@sq.uucp (David R. Seaman) Followup-To: comp.bugs.misc Organization: SoftQuad Inc., Toronto Lines: 71 Keywords: Ackkfft yacc lex Checksum: 13744