Re: RPN as intermediate code?

ukln@rzstud2.rz.uni-karlsruhe.de (David Furminieux)
Thu, 31 Aug 1995 14:30:50 GMT

          From comp.compilers

Related articles
RPN as intermediate code? gorelick@esther.la.asu.edu (1995-08-22)
Re: RPN as intermediate code? lkaplan@BIX.com (1995-08-25)
Re: RPN as intermediate code? jaidi@technet.sg (1995-08-26)
Re: RPN as intermediate code? odersky@ira.uka.de (1995-08-29)
Re: RPN as intermediate code? ukln@rzstud2.rz.uni-karlsruhe.de (1995-08-31)
Re: RPN as intermediate code? hbaker@netcom.com (1995-09-02)
Re: RPN as intermediate code? mejohnsn@netcom.com (1995-09-11)
Re: RPN as intermediate code? bevan@cs.man.ac.uk (1995-09-06)
Re: RPN as intermediate code? Robert.Corbett@Eng.Sun.COM (1995-09-12)
| List of all articles for this month |
Newsgroups: comp.compilers
From: ukln@rzstud2.rz.uni-karlsruhe.de (David Furminieux)
Keywords: interpreter
Organization: University of Karlsruhe, Germany
References: 95-08-164
Date: Thu, 31 Aug 1995 14:30:50 GMT

Noel Gorelick (gorelick@esther.la.asu.edu) 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)


    in


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


--
    Dave
& have a good night


* D. G. Furminieux ukln@rzstud1.rz.uni-karlsruhe.de *
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.