WIP compiler written in C#. The compiler translates a small custom language into instructions for a simple virtual machine. The code is a work in progress and was created around the same time as the author's virtual machine project (2021/2022).
The language resembles a very small imperative language with C-like syntax. Supported features include:
- Data types:
byte,word,dword,qword,string,bool, anddetermine. - Variables: declared using
[type] [name] = [value];. - Functions:
function name([param list]) returns [type] { body }. - Function calls with parameters.
- Control flow:
while(condition){ ... }andif(condition){ ... }with comparison operators such as==,!=,>=,<=,<,>. - Built‑ins:
print(string)andadd(qword,qword)are predefined.
Comments start with //* and continue to the end of the line.
print("Hello, world!");
The corresponding output generated by the compiler is stored in samples/hello.asm and looks like:
entry strout "Hello, world!" ret
A C# compiler (such as mcs from Mono or the .NET SDK) is required. To build the project using mcs:
mcs -out:Compiler.exe Compiler.csRunning the resulting executable will assemble and execute main.vmc located next to the binary:
mono Compiler.exeReplace mono with dotnet if you build using the .NET SDK. Since the codebase is incomplete, compilation may require additional dependencies or modifications.
See the samples directory for a minimal example.