Subject: Re: function name

From: Zheng Gengbing <[email-masked]>
Date: Mon, 27 May 1996 16:50:56 +0800 (EAT)

On Fri, 24 May 1996, Guansong Zhang wrote:

> When I try to solve the problem met by flex. I have the following question:
> 
> first: in hpflexer.l we have:
> 
>    999
>     if((i=searchKey_m(name,FUNC_TAB_G,FUNC_TAB_LIMIT_G))<FUNC_TAB_LIMIT_G)
>   1000          {
>   1001       if (intrFlag_g ==1) return (NAME);
>   1002       do {
>   1003               chara=input();
>   1004               }while(chara==' ');
>   1005           if(chara=='(')                 /*** "funname( )" : FUNNAME
>  ***/
>   1006                 { unput(chara);
>   1007               if(debugFlag_g==1)
>   1008                      printf("(func_name: %s  %d)\n",name,i);
>   1009                   return(FUNNAME);
>   1010                 }
>   1011            else
>   1012                 { unput(chara);
>   1013                   return(NAME);
>   1014                 }
>   1015          }
> 
> One thing that afects flex to parse our project is that in this segment of
> program, there is input and output, which have different meaning between lex
> and flex.
> 
> Then I try to find out why these two function were used. I am lost.
> 
> >From the above, it seems we need a token FUNNAME.
> 
> Look up this token, I found the following in f90.y:
> 
>   5494  func_ref_name
>   5495      :  FUNNAME {
>   5496            char *tmp;
>   5497            char *trim_blank();
>   5498
>   5499            if(debugFlag_g==1) printf("funname %s\n");
>   5500            tmp = trim_blank(yytext);                 /* zheng.gb
> 1996.5.15 */
>   5501            $$ = makeSymbUnithead(fi,FUNCTION_NAME,tmp);
>   5502            }
>   5503      ;
> 
> You can see that it is the only place this token is used.
> 
> Now lets see func_ref_name, the following is the only place it is used.
> 
>   5481      |  func_ref_name LEFTBRACKET RIGHTBRACKET {
>   5482            $$ = makeLlnd(fi,FUNC_CALL,LLNULL,LLNULL,$1);
>   5483            $$ -> type = $1 ->type;
>   5484            if(debugFlag_g==1) printf("func_ref : %s\n",$$);
>   5485            }
>   5486      |  func_ref_name LEFTBRACKET
>   5487         actual_arg_spec_list RIGHTBRACKET {
>   5488            $$ = makeLlnd(fi,FUNC_CALL,$3,LLNULL,$1);
>   5489            $$ -> type = $1->type;
>   5490            if(debugFlag_g==1) printf("func_ref : %s\n",$$);
>   5491            }
>   5492      ;
> 
> But I don't understand the signifance of this token's usage.
> 
> It seems from lexer point of view, we are trying to recognize the following:
> 
> a = sin (a)
> 
> 's right hand side as a function.
> 
> But what about when we meeting:
> 
> a=my_sin(a)
> 
> Once, PKU talk about similiar question concerned with intrisinc function call.
> This question also concerned with keyword problem. So please think it
> carefully. I am waiting your comments.
> 
> Don't do any change until we are clear about this please. (I think once we find
> the problem is caused by input and unput, it will be easy to figure out how to
> let flex pass.)
> 
> Guansong
> 

	In fact , we can remove the step to examine if a name
is FUNNAME or NAME , and simply return NAME in lexer .
	We have done the same search in hpfsc once again .

	But input & unput problem still exists and it will keeping 
disturbing us in other cases .

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

---

From: Zheng Gengbing <[email-masked]>
Date: Mon, 27 May 1996 18:37:10 +0800 (EAT)

Hi,

	I have a prblem when I use bison to compile the yacc file .
The first token in hpfparser.tab.h is 
#define FORMAT 257
when using yacc ,

while 
#define FORMAT 258   in bison ,

how can I find out which number the first token begin ?

So the code should be changed from 

		/* returnValue_m=257+i; */
to
                returnValue_m=FORMAT+i;    /* modified by zheng.gb */

in order to get correct result .

and the error.file should also be adjusted .