DemeterF/DemfGen
Compiler/Assembler Example
This is an example compiler for a simple functional "let"
lanuage. The mini language is compiled into a simple stack based
assembly language that includes labels, jumps, and branches.
Below are the related files for the languages and the compiler
written in
DemeterF and
DemFGen.
I've written both Java and C# versions to demonstrate the
usefull nature of correctly written CD files. It also gives me a
chance to make sure the DemFGen Java and C# code generation works
as expected.
DemFGen Lib CD File:
Jars/Tars:
Compiler:
Types:
Asm/Execution:
Example Input:
(let a = 7 in (if (< 4 3) (* a 2) (/ a 2)))
Generated Ouput Code:
push 7
def
push 3
push 4
less
ifzero else_0
push 2
load 0
times
jump done_1
label else_0
push 2
load 0
divide
label done_1
undef