Re: yytext in POSIX lex

vern@daffy.ee.lbl.gov (Vern Paxson)
Fri, 5 Feb 1993 21:26:32 GMT

          From comp.compilers

Related articles
yytext in POSIX lex amin@unirsvl.RSVL.UNISYS.COM (1993-02-03)
Re: yytext in POSIX lex schrod@iti.informatik.th-darmstadt.de (1993-02-04)
Re: yytext in POSIX lex vern@daffy.ee.lbl.gov (1993-02-05)
| List of all articles for this month |
Newsgroups: comp.compilers
From: vern@daffy.ee.lbl.gov (Vern Paxson)
Keywords: lex, design
Organization: Lawrence Berkeley Laboratory, Berkeley CA
References: 93-02-035
Date: Fri, 5 Feb 1993 21:26:32 GMT

> [Of the two major implementations of lex, AT&T lex makes yytext an array
> and flex makes it a pointer .... You have to try fairly hard to tell
> the difference, e.g. use sizeof(yytext). -John]


One major problem is that if another source file declares yytext as


extern char yytext[];


and the lex-generated code declares it as


extern char *yytext;


(or vice versa), then on systems without type-safe linkage the program may
link without any warning or error, but crash at run-time when yytext is
accessed. It was this argument that led to the (crufty) adoption of
%pointer and %array.


Vern


Vern Paxson vern@ee.lbl.gov
Systems Engineering ucbvax!ee.lbl.gov!vern
Lawrence Berkeley Laboratory (510) 486-7504
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.