|RPN as intermediate code? email@example.com (1995-08-22)|
|Re: RPN as intermediate code? lkaplan@BIX.com (1995-08-25)|
|Re: RPN as intermediate code? firstname.lastname@example.org (1995-08-26)|
|Re: RPN as intermediate code? email@example.com (1995-08-29)|
|Re: RPN as intermediate code? firstname.lastname@example.org (1995-08-31)|
|Re: RPN as intermediate code? email@example.com (1995-09-02)|
|Re: RPN as intermediate code? firstname.lastname@example.org (1995-09-11)|
|Re: RPN as intermediate code? email@example.com (1995-09-06)|
|Re: RPN as intermediate code? Robert.Corbett@Eng.Sun.COM (1995-09-12)|
|From:||firstname.lastname@example.org (David Furminieux)|
|Organization:||University of Karlsruhe, Germany|
|Date:||Thu, 31 Aug 1995 14:30:50 GMT|
Noel Gorelick (email@example.com) wrote:
: x = a*(b+c) -> "a b c + * x ="
: y = sqrt(b*b-4*a*c) -> "b b * 4 a * c * - 1 sqrt callfunc y ="
: z = foo(a,bar(b),c) -> "a b 1 bar callfunc c 3 foo callfunc z ="
: (actually, all the identifiers and constants go into a dictionary
: and are replaced by a lookup index, but you get the idea...)
: However, when I get into conditionals and loops, I have absolutely no idea
: how to proceed. Do I really have to get all the way down to the level of
: computing jump offsets and implement these as conditional gotos? Or is
: there a more elegant way that I just haven't found yet?
Ok I am not a compiler specialist, but I am quiet used to use
the HP48 wich is fully RPN
so I thought liske that
first replace '=' with STO wich would be much more general
like << 1 + >> 'INC' STO to create the INC function
now you could do
z = if b then a*(b+c) else sqrt(b*b-4*a*c)
<< b c + a * >> X STO << b b * a c 4 * * - >> Y STO
X Y b IFTE
it is important to understand that the form << >> will not execute
the stuff inside but only define a function
and the IFTE function would be
taking b from the stack if b is true then drop the first element from the
stack and execute the second, if not swap the elements drop execute
Hope this will help
& have a good night
* D. G. Furminieux firstname.lastname@example.org *
Return to the
Search the comp.compilers archives again.