Subject: Re: bug about constant literal

From: Zheng Gengbing <[email-masked]>
Date: Tue, 18 Jun 1996 18:48:59 +0800 (EAT)

On Mon, 17 Jun 1996, Guansong Zhang wrote:

> Here is a def bug: (It's the only bug prevent recompile program from NAG)
> 
>         program test
>         K=-1
>         D=I*(-J)/4
>         end
> 
> In the 1.57 will unparse as following:
> 
>         program test
>         K=(-(1))
>         D=I*(-(J))/4
>         end
> 
> 
> It is not wrong at all. The only problem is that to MINUS_OP, unparse deal in
> this way: first print a "(", then "-", "(" again, unparse LL1, finally print
> "))". That is why we have the above matched ()s.
> 
> The problem comfrom the following sentence in NAG program, there is something
> like:
> 
> complex (kind=wp):: c=(0.06659252_wp, -0.01398327_wp)
> 
> Then when unparse it, it will be:
> 
> complex (kind=wp):: c=(0.06659252_wp, (-(0.01398327_wp)))
> 
> According to F90 syntax, this is not allowed. The second arguments should be a
> constant literal. (IBM's F90 allow this, then it has some kind of extention.
> But not the case on DEC.)
> 
> So, I changed the unparse method, omit those ()s in them. Then this sentence is
> OK, but the above program will be unparsed as this:
> 
>       program test
>       K = -1
>       D = I * -J / 4
>       end program
> 
> Which is wrong this time.
>

	Why it is wrong ?
	when D=I*(-J)/4 , the () is redundent , because unary minus have
higher priority.
 	If you cannot unparse the () , it is because it is really redundent.

> So the def for this MINUS_OP (or expression includes it) pose a problem. It
> does not follow the root first rule. Please redefine it.
> 
> My suggestion is that let the expression inlude change a little, in the above
> program, do not let the 7-E be MINUS_OP directly, let it be an EXPR_LIST whose
> LL1 be a MINUS_OP, so unparse can unpare MINUS_OP without print out ()s, and
> the () needed will be printed out when unparsing EXPR_LIST.
> 
> Any way, let me know your decision.
> 

	In fact , AST did not contain the information of () , so unparser
cannot unparse them strictly. But the AST is correct ,think about the
2-branch tree to represent the expression when we learned in compilation
course , it remove the () information automatically after construct the tree.
There is no need to () every expression .

Gengbin