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:
Lib.cd
Jars/Tars:
java-compiler.jar: includes all Java related files
cs-compiler.tgz: includes all C# related files
Compiler:
CD File
Java Compile Class: HTMLized :: Plain Java
  C# Compile Class: HTMLized :: Plain C#
Types:
CD File
Java TypeCheck Class: HTMLized :: Plain Java
  C# TypeCheck Class: HTMLized :: Plain C#
Asm/Execution:
CD File
Java BEH File
C# BEH File

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