Enter an arithmetic expression here:
Parsed (AST converted to an S-expression):
Compiled (to x86 assembly, Intel Syntax):
Interpreter output: null
WARNING: The tokenizer, the parser and the compiler
appear to generate correct results, but they haven't been rigorously tested.
Also, no optimization is being performed (aside from perhaps the code being the
one it's easiest to compile into). To test the code the compiler generates,
you can download the fully-prepared project file (for your arithmetic expression)
that can be compiled using FlatAssembler on Windows by clicking
(although it works in Internet Explorer 6, it doesn't work in some later browsers). In case that doesn't work, you
can download an example testing project here (comments are in Croatian). If you want
to have a command-line app with the same functionality and some more (if-else, while-loops, arrays, the support for the assembly language compilers that don't support automatic floating-point-to-IEEE754 conversion...),
you can download the source code of the version of this app runnable in Duktape (a lightweight and easy-to-use alternative to NodeJS)
here (or, if you are willing to risk getting viruses from my computer, you can download the executable files from GitHub here.). You can also download a Notepad++ script for syntax-highlighting of that language here. Neither do I, nor do the creators of FlatAssembler, nor does 000webhost (a Cyprus-based
company hosting this website), claim any liability for the damage those programs may do to your computer.
It's a part of the Terms of Service for me not to make scripts that install executable files to your computer. Scripts that
produce compilable Assembly language files do not violate the Terms of Service as they are not
executable files themselves. However, once they are compiled using FlatAssembler, nobody can
guarantee you (including the antivirus software) they won't do any damage to your computer. It is not my intention to damage
your device, but remember that if you compile the files you download here (using FlatAssembler),
you will be running arbitrary Assembly language code on your computer, and be careful with it
(for maximal security, I'd recommend using some virtual machine software).
By the way, if you ever find yourself having to use a programming language without a built-in math library, here is an example of how to make a simple math library in less than 150 lines of code.
UPDATE on 15/10/2018: You can download my presentation (in Croatian) about how
the compilers work here (It's a ZIP archive containing
an ODP file, a PPT file and a PDF file, all saved from Impress. Hopefully, your computer can usefully open at
least one of those files!).
UPDATE on 18/10/2018: If you have a modern browser, you can see the AST diagram
by clicking here (it requires a relatively
advanced SVG support, seen in, for example, Internet Explorer 11). If you don't have,
don't worry, graphical representations of complex (that can't be done by hand) ASTs
are useless (the maximal depth of a useful graphical AST is probably around 5).