Please note that this article describes an initial implementation of the compiler. If you want to browse the code while reading the article, make sure that you have switched to branch dsl_v1.
In my toy compiler framework, a compiler (or codegen as it is called internally), is a piece of code that implements the ISimpleDSLCodegen interface. This interface exposes only one function, Generate, which takes an abstract syntax tree and converts it into an object implementing an ISimpleDSLProgram interface which allows you to call any function in a compiled program by name.
type
  TParameters 
= 
TArray; 
  
TFunctionCall 
= 
reference 
to 
function 
(const
parameters:
TParameters):
integer;
  
ISimpleDSLProgram 
= 
interface 
['{2B93BEE7-EF20-41F4-B599-4C28131D6655}']
    
function 
Call(const 
functionName: 
string; 
const 
params:
TParameters;
      var
return:
integer):
boolean;
  
end;
  
ISimpleDSLCodegen 
= 
interface 
['{C359C174-E324-4709-86EF-EE61AFE3B1FD}']
    
function 
Generate(const
ast:
ISimpleDSLAST;
      
var runnable: ISimpleDSLProgram): boolean;
var runnable: ISimpleDSLProgram): boolean;
  
end;
 
