Mano-compiler is a project mainly written in Python, it's free.
A simple HLL compiler for the Mano Machine.
Mano Compiler is a proof-of-concept compiler that converts a simple high-level language into the 25-instruction assembly dialect accepted by the Mano Machine. The result can then be assembled and executed on a simulator.
The language supports integer, array and string data types, functions, and textual output of any variable. Being a proof of concept, it also has some flaws, including sharing of local variables (but not arguments) between instances of the same function during recursion and lack of support for reading input during runtime (partly due to lack of simulator support).
The compiler is written in Python 2 and does not use anything outside the standard library. It is portable to any platform that supports Python, and can be used to generate large amounts of assembly code to test new implementations of the machine or its simulator.
Although it has little practical use, it may have educational value as an example of a very simple compiler that covers the whole path from reading plain text source code to emitting final assembly code in about 1K lines of code.
The compiler is invoked from the command line and passed the name of the file containing the source code to be compiled, and optionally the name of the output file. The -O flag can be used to produce optimized code.
Once compiled, the code can be run using a simulator. However, due to the lack
of linking, the runtime library used by the compiler (included in the
distribution) has to be loaded manually. In manosim.exe
, the whole sequence of
assembling, loading and running a compiled program looks like this:
* source lib
[Some assembly information, including identifier list.]
* source compiled_filename
[Some more assembly information.]
* go
[Output of the program goes here.]
A language definition and some example code is included in the resources folder.
There are several simulators for the Mano machine, although each has its own problems:
manosim.exe
or mano2.exe
, the one
explicitly targeted by this compiler and included in the Windows
distribution download works well, but it is a DOS program, and does not run
natively on 64-bit Windows systems, much less any kind of UNIX. However, it
can be convinced to work in DOSBox or on a 16- or 32-bit virtual Windows
machine. I was unable to track down its source code to recompile it.This code is licensed under the MIT licence.