Compilers for higher order langauges often use different forms
of temporary representations of the program.
In A normal form the program source is linearized and all
temporary results are named. It is therefore easy to produce
assembler from normalized programs.
The linear time algorithm below transforms expressions in
CoreScheme? into A Normal Form. The algorithm is from
"The Essence of Compiling with Continuations" by
Cormac Flanagan, Amr Sabry, Bruce Duba and Matthias Felleisen.
The programming technique used was pionered by Danvy and Filinski.
The abstract syntax for CoreScheme? and the corresponding A normal
form is:
;; Abstract syntaks for Core Scheme (CS)
M ::= V Values
| (let (x M) M)
| (if0 M M M)
| (M M ... M)
| (O M ... M) Primitive Operations
V ::= c Constants
| x Variables
| (lambda x1 ... xn . M)
;; A-normalized CS
M ::= V (return)
| (let (x V) M) (bind)
| (if0 V M M) (branch)
| (V V1 ... Vn) (tail call)
| (let ((x (V V1 ... Vn))) M) (call)
| (O V1 ... Vn) (prim-op)
| (let ((x (O V1 ... Vn))) M) (prim-op)
V ::= c | x | (lambda x ... x . M) Values
500 Can't connect to 127.0.0.1:8778 (connect: Connection refused)