Subject: Re: Portability

From: Zheng Gengbing <[email-masked]>
Date: Thu, 23 May 1996 16:19:56 +0800 (EAT)

On Wed, 22 May 1996, Guansong Zhang wrote:

> >
> > 	can you tell me which line did you commented out ?
> 
> Well, I said the line about definition of yytext.
> 
> /* extern  char yytext[YYLMAX];   yytext[0x400] (sun20) ; *yytext  (Linux) */
> 
> the old one looks like:
> 
> extern  char yytext[YYLMAX];  /* yytext[0x400] (sun20) ; *yytext  (Linux) */
> 
> in 1.53.
> 

	yytext always causes troubles . Sometimes it is decalred as
unsigned char yytext[] , while sometimes char yytext[] , to make thing worse,
sometime flex also define  char *yytext (pointer instead of array ).

	To eliminate the first difference , I used  
#undef YYCHAR_ARRAY 
	to force the compiler to adopt the definition of char yytext[] .

	To the second case , I used   %array yytext
to tell the lex to define the yytext as array instead of pointer .

	So please test if the lexer and parser can be smoothly compiled
in the coming version . My test on HP and Linux is successful .

> 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 .

***************************************************************************
*     Zheng Gengbin                 *                                     *
*                                   *                                     *
*  Dept. of Computer Science        *  Phone:  86-10-2585088              *
*         & Technology              *  Email:                             *
*                                   *      [email-masked]   *
*  Peking University P.R.China      *  Mail:                              *
*                                   *      Room 1077 ,Building 47,        *
*                                   *      Peking University, P.R.China   *
***************************************************************************