Subject: Re: combining hpf2dep and hpfcc

From: Zheng Gengbing <[email-masked]>
Date: Fri, 26 Apr 1996 08:59:46 +0800 (EAT)

On Thu, 25 Apr 1996, Guansong Zhang wrote:

> We have discussed about the hpf2dep and hpfcc. Now let's make the final
> decision on what it will be look like at the demo.
> 
> (So an user interface using HTML and CGI can be developed. Then our work can be
> showed at any place can connected to internet.)
> 
> In another words, we have to decide whether the interface can see both hpf2dep
> and hpfcc. Right now, we can consider whether let the unparse to see both of
> them. I mean if both of their output will be taken as input by unparse.
> 
> The following is my opinion:
> 
> 1. If we decide to let both of them be seen, we have to make distingushed line
> between the function of two.
> 
> >From the following, should we drew the conclution that it is impossible?
> 
> On Apr 25,  9:10am, Zheng Gengbing wrote:
> >
> > 	Unlike C language , Fortran has its own features . As I think ,
> > to expect to construct whole AST in correct mode in the first pass in
> > impossible .
> > 	Something do have to be decided in the second parse . Let me give
> > an example , this case will always occurs in the forword-reference .
> >
> > 	PROGRAM main
> > 	a = f(3)
> > 	END main
> >
> > 	FUNCTION f(k)
> > 	f=k+1
> > 	END
> >
> > 	Now , how do you know the f(3) is an array or a function call ?
> > So in the first parse , just let it be . We can decide the type of f(3)
> > only after yacc parse all the file , after that we can search the AST
> > created by yacc , and find the function f  backwards.
> >
> > 	Anyway , this maybe is of no importance to unparser temporarily ,
> > because you can always unparse  array and function call in same look in
> > HPF . But , please notice , if you want to unparse  this program to C , you
> > will meet the trouble .
> 
> > ...
> 
> > 	You know some semantics checking depends on the information which
> > can only be obtained after yacc parse all the file. That is the problem
> > we must face to.
> >
> 
> I am sure, in practice there will be a lot of this kind of problems. But it
> does not necessaryly mean unsolvable.
>

	If we divide the hpfcc , take part work of our pass to hpf2dep , in 
theory it is possible , though the work is huge .  It is something like 
we must rewrite the whole structure of hpf2dep.

	And since in hpf2dep , the work is to construct a AST tree , and the
work of hpfcc is to parse the tree . Why devide hpfcc and add into hpf2dep
a parse of AST .This also make the line unclear .

> Why can't we divide the hpf2dep and hpfcc by building up the tree and checking
> the tree? (adding several more redundant links to facilitate the process is
> accepted, but changing things like tag and the main trunk is something
> different)
> 
> If fortran's feature does not allow building an accurate tree at yacc time with
> one pass. We can add one more path in hpf2dep. This certainly can solve the
> problem above.

> (In fact to this specific problem, we may even don't need
> another pass, if an array is to be refferenced, it should be declared first,
> other wise this pattern should be considered as a function. 

	Does the HPF specification say this word ?

> This can
> implemented in yacc action. Though, I don't think it is necessary to do so, it
> will complicated the yacc action job.)
> 
> Then we use one more pass to finish semantics checking job.
> 
> I don't know by doing this how much code will be left in the third pass. If
> almost nothing, we'd better do it in the second way.
> 
> 2. Let the hpf2dep and hpfcc as a whole unit.
> 
> So we will think in the following idea:
> 
> On Apr 25,  9:10am, Zheng Gengbing wrote:
> >
> > 	I am glad you have somehow understood the work of hpfcc , but
> > to say that the AST produced by first parse is meaningless is so pessimic ,
> > most of the AST is well built . And to unparse a AST which is not be semantic
> > checking is also meaningless , why must unparse before hpfcc ?  The output
> > of hpfcc is really the outcome of compilation of HPF frontEnd , don't you
> > think so ?
> >
> >-- End of excerpt from Zheng Gengbing
> 
> In this way, the user of the unparse should not think the out put from hpf2dep
> is unparsable. (Though in practice, it may just print out the correct form of
> the program.) At this point we only have partial built AST. Right? (So I use
> the word "meaningless", may be not the right word.)
> 
> Its a little awkward to have two command lines to complish one thing, so I like
> to know if pku can combine the hpf2dep and hpfcc together while waiting hit's
> new yacc rules.
> 

	Ok , I will try .

> If this need too much time, let the interface use shell script do it. We should
> take care of their error message (any message print out to the screen) to make
> them looks like generated from one program instead of two.

	We are using the shell script to do the work , in fact we already
have one .

	Here is a  shell script . If you want to use it , do not forget to
change the path of hpf2dep ... .

> 
> 
> Above a two options, I hope pku can make the desicion which way we will use.
> 

	I think the second one is a better one .

***************************************************************************
*     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   *
***************************************************************************
if [ ! $# = 1 ]
then
        echo  [Usage:]  v file.f
        exit 1
fi

if [ ! -f $1 ]
then
        echo  Error: "$1" not exist !
        exit 1
fi

! get .dep name
depfile=`echo $1 | sed '/\./s/\..*/\.dep/' `

! get .dump name to save the dumpdep result 
dumpfile=`echo $1 | sed '/\./s/\..*/\.dump/' `

if [ $1 = $depfile ]
then
	echo Invalide file name "$1"
	exit 1
fi

echo --------  NPAC Compile "$1"
        ~/NPAC/hpfFrontEnd-1.2/src/hpf2dep/hpf2dep   $1

echo
echo -------- NPAC Recompile $1
	if [ -f $depfile ]
	then
		~/NPAC/hpfFrontEnd-1.2/src/hpfcc/hpfcc     $depfile
	else
		echo  $depfile not found !
		exit 1
	fi

echo
echo --------  DUMP  "$depfile > $dumpfile"
        ~/NPAC/hpfFrontEnd-1.2/src/tools/dump/dumpdep  $depfile > $dumpfile

echo
echo -------- View $dumpfile
        xterm -e vi $dumpfile &