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:
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 statement Else statement EndIf While expression statement Wend Input var1[, var2...] Print [,]var1[{,|;}var2] PrintLine [,]var1[{,|;}var2] var = expression supported operators: +, -, *, /, (, ), AND, OR, NOT, <, <=, >, >=, <>, =
The build process is a three step process:
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:
Compile a FemtoBasic program. For example to compile sample.bas:
br sample
If everything went well, you'll have sample.exe