Here's the modified result of going through Jack Crenshaw's "Let's Build a Compiler" pdf If anyone's interested.  If you want to read the original pdf's the links on the left.

Here's some of the differences:

  • Written in PowerBASIC not Pascal
  • Generates x64 applications not 68000
  • Language is "Basicish" instead of "Pacalish"
  • Some names were changed, made them longer and more applicable
  • Moved a few things to classes
  • The program was changed from Tiny11 to FemtoBasic

You can target a new processor by implementing iCodeGen and creating your new code generator in Initialize.

The input and output routines are in interfaces. If you implement a string based iInput, you could compile from memory or pipe the output to StdOut.

It supports the following keywords:

Dim var1[, var2...]
If expression Then 
While expression 
Input var1[, var2...]
Print [,]var1[{,|;}var2]
PrintLine [,]var1[{,|;}var2]
var = expression
supported operators: 
+, -, *, /, (, ), AND, OR, NOT, <, <=, >, >=, <>, =

The build process is a three step process:

  • Run FemtoBasic against your source to create an assmbly source output.
  • Run Jwasm against the assembly to create a .obj file
  • Run Jwlink against the .obj file to create an x64 .exe file.

To run your program you'll need to download JWAsm and JWLink.
  • Jwasm -
  • Jwlink -
  • WinInc -

If you want to run a debugger you'll need to download
  • PellesC -


jwasm -c -win64 -Zp8 -Sg -Ic:\asm\Include;c:\asm\MyInclude -Fl=%1.txt %1.asm
Add -Zd -Zi for debugging

JWLink linking
jwlink.exe file %1.obj name %1.exe libpath c:\asm\Lib64 libpath c:\asm\MyLib64 runtime console

PellesC linking - smallest output
polink.exe %1.obj /OUT:%1.exe /libpath:c:\asm\Lib64 /libpath:c:\asm\MyLib64 /subsystem:console
Add /debug for debugging

To get stuff setup with a minimum of fuss:

  • Install jwasm, jwlink, and wininc in c:\asm
  • Add c:\asm to your search path
  • create c:\asm\MyInclude, copy into it.
  • create c:\asm\MyLib, copy curion.lib into it.

Compile a FemtoBasic program. For example to compile sample.bas:

br sample

If everything went well, you'll have sample.exe