Contents    Page-10    Prev    Next    Page+10    Index   

RPN as Intermediate Code

An entire program can be expressed in Reverse Polish intermediate code. For example, by reading the pretty-printed intermediate code from graph1.pas into Lisp and converting it to RPN, the following is obtained:


(I 0 := 1 LABEL I 32 <= X 0.0625 I FLOAT * :=
 Y EXP X - FUNCALL SIN 6.28318 X * FUNCALL * :=
 N ROUND 32.0 Y * FUNCALL 34 + := 0 LABEL
 WRITE " " FUNCALL N N 1 - := N 0 = PROGN
 0 GOTO IF PROGN WRITELN "*" FUNCALL
 I I 1 + := 1 GOTO PROGN IF PROGN)
It must be clear how many operands each operator takes, so a construct such as progn must be replaced by prog2, prog3, etc.