Subject: Re: YYTEXT

From: Zheng Gengbing <[email-masked]>
Date: Wed, 29 May 1996 15:58:37 +0800 (EAT)

On Tue, 28 May 1996, Guansong Zhang wrote:

> On May 24, 11:21am, Zheng Gengbing wrote:
> > Subject: Re: Portability
> >
> >
> > > > > I found autoconf package has some special places about whether the
> > > definition
> > > > > is pointer or an array for yytext. But I don't how to use it. Zheng
> > > Gengbin, do
> > > > > you have any idea, please?
> > > > >
> > > >
> > > > 	I once used the YYTEXT_POINTER to determine the definition . But ,
> > > > I found that is not successful . As mentioned in the man page of flex ,
> > > > use yytext as pointer will cause some portablity problem though using
> pointer
> > > > can make  the parser fast .  So to force the lex to define the yytext as
> > > > array is better , I think. If we use %array yytext , we can force the lex
> > > > to define yytext as array , then we need not use YYTTEX_POINTER .
> > > >
> > >
> > > I agree with you, but I don't quite understand the situation now.
> > >
> > > If we comment that line in .l file out, if it is still a problem. I found
> the
> > > following lines in hpflexer.c and hpfparser.c respectively on 1.55.
> > >
> > > hpflexer.c:unsigned char   yytext[YYLMAX];
> > >
> > > hpfparser.c:char yytext[0x400]; /* *yytext (Linux);  yytext[0x400] (Sun20)
>  */
> > >
> > > >From what I understand you said, the first one is generated by the lex(or
> flex)
> > > by forcing %array. But the second one have to be declared in .y file, so it
> can
> > > be referenced some place else in .y, right?
> > >
> >
> >
> > 	This is the real problem now .
> >
> >
> > > I don't see any relations between them in the above, is the second one
> should
> > > be declared as extern? Please check this.
> > >
> > > Then how we can know whether we should declare yytext as char or unsigned
> char?
> > > %array will force an unsigned char?
> > >
> >
> >
> > 	I don't know either . I will examine other gnu softwares to see how
> > they deal the problem.
> >
> 
> Now it is still a problem about yytext in .l file. On mips-sgi-irix5.3 and
>  sparc-sun-solaris2.4 lex do not support %array, you need to comment the line
> out to let it pass the hpflexer.l.
> 
> So, it seems we still need test whether it is a pointer or an array if we want
> let it pass by most lex.
> 
> Any way, if it is a pointer, an additional buffer should be allocated for
> yytext, is there any other problem for this?

	As I know , there are some side effects about pointer . It will
destory the content of  yytext when unput is called . You can refer to
the man page of the flex . It really cause a problem to portability.

Zheng