Subject: Re: Explanation on 1.32 ...

From: Zheng Gengbing <[email-masked]>
Date: Mon, 29 Apr 1996 10:51:25 +0800 (EAT)

On Sat, 27 Apr 1996, Li Xinying wrote:

> Hi,
> 
>    I think you have seen the hpfFrontEnd-1.32,which based on 1.31,Zheng 
> qiang and I did many changes on it. The changes center on hpf2dep,
> such as files:
>       f90.y fD.y hpflexer.l keywords.h ... 
> I hope the new version would satisfy all of us  in grammar rules.
> 
>    The changes removed grammar bugs of " non_program_head , use_only,
> implicit,io, format ".  Most bugs detected in the TestSuite.tar I got 
> from Zhang guansong are not real bugs. I explained "testh.f" in the last 
> email sent to you by Zheng qiang and "test1.f" in attachment file of 
> this email.
> 

	I will say your change is not successful , I am afraid .
	I have no time to explain this today , I will give you an example :

assignment_stmt
    :  variable EQUAL expr in_prog |
       name LEFTBRACKET RIGHTBRACKET EQUAL expr in_prog 

	In this rule , the variable is created before you reduce the 
in_prog . That is when variable is reduced , the scope is NULL, the variable
now have no scope if it is newly created  . This condition will happen when 
	a = 9
	and 'a' is a variable using implicit rules which has not been ever 
declared.

	And I think your change is not elegant , it damage the beauty of
the rule .

	In that case  I think you should use the method I mentioned in my 
previous letter . Create a PRO_HEDR when the end of every program_unit , and 
push to the scope table .
	If the next program_unit is not a main program , then there is also 
no need to create a new BFND , just change the variant of PROG_HEDR to  
MODULE , FUNCTION or so. 
	There is still two problems :
	1. You must set a variable to indicate if a subprogram is not
	   a internal subprogram in contain block .If it is in contain block,
	   no need to create PRO_HEDR at the end. 
	2. At the end of parsing , do not forget to delete the 
		redundent PROG_HEDR created .
	
	I think use this method , you will only change the 
1.	makeProgram(), makeModule(), makeBlock(), makeFunction(),
	makeSubroutine() in makespec.c .

2.	and add  makeProgram to these yacc rules:
	end_module_stmt ,  end_block_data_stmt ,
	end_function_stmt , end_subroutine_stmt.
	
3.	add a global variable to indicate contains .

4.      at the end of parse , delete the PROG_HEDR .

	Please think it over if this method is applicable .

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