Almost the whole codebase of the project was written in the 2nd semester (1st year) of study at MIPT.
CMM Compiler is an advanced version of CMM language pack with translation program-code directly to executable file .exe
.
All the syntax is written here. But there are some important changes:
- Instead of
double
type of every variableint
is used. - Because of usage of general registers there is no sense to keep such functions as
sin
, ...,ln
, because they work only withdouble
values. So all trigonometric, hyperbolic functions are removed,exp
andln
are removed. They are just ignore while generating executable file, so all responsibility lies with you, if something doesn't work because of it. - At the same time the only expression type in
deriv
function is a polynomial, that's why this function is removed too because of its diminishing its meaning. - Operator
^
and functionpower
are removed, because CPU doesn't support power instructions (do it manually).
Despite the fact that there are a lot of changes, CMM is still full-Turing language.
With considering all changes in syntax frontend
, optimizer
and reversed frontend
are used in the same way, as in old CMM version.
This part of CMM language is worth separate consideration, because there are a lot of changes.
First of all, now there is no such strata between program and executable file as assembly code. Now all CMM program compiles directly into .exe
file. Also executable code is analyzed by CPU directly, without any interaction with other program, such as nCPU
like in old version.
All generated programs are always 32 bit
.
Functions print
and scan
are supported by sfasmlib.dll
library (Simple and Fast Assembler Library), which imports PrintNumber
and GetNumber
functions and uses kernel32.lib
. Also this library imports ExitProgram
, which calls ExitProcess
function.
How is was already noticed, the usage of CMM language is the same except compilation:
./lang_compile.exe program.tree program.exe
First, you should build the project. Clone current repository:
git clone --recurse-submodules https://github.com/Vokerlee/CMM-Compiler.git
Then enter cloned repository and create build directory and use cmake
like this:
mkdir build && cd build
cmake ..
Now you can use any build system you desire (like Ninja
) and build the project.
On the average now CMM compiled program executes 2500 times faster than old version because of many reasons.