Hopefully, a C to WebAssemply compiler.
Demo of compiled program running on browser
- Make
- Flex
- Bison
- Clang
sudo pacman -S make flex bison clang
sudo pacman -S nodejs wabt
sudo apt install -y make flex bison clang
suto apt install -y nodejs
Get wabt
from https://github.com/WebAssembly/wabt/releases or whatever. wabt
is also avaiable on Nixpkgs.
make
make test-parsing
make test-codegen
Run a console version of the 2048 game written in C compiled to Wasm:
./run_codegen_tests.sh 2048
src/ - "library" sources
main/ - .cpp files that compile to executables
runtime/ - JavaScript runtime
tests-parsing/ - test files for parsing
input/ - inputs
ast-dot/ - rendered ASTs
tokens/ - dumped tokens from input files
tokens-expected/ - expected token dumps
output/ - stdout and stderr outputs
output-expected/ - expected outputs
tests-codegen/ - test files for code generation
- Make:
4.3-3
(Arch);4.1
(Ubuntu Bionic) - Flex:
2.6.4-3
(Arch);2.6.4-3
(Ubuntu Bionic) - Bison:
3.7.2-1
(Arch);3.7.2
(Nix) - Clang:
11.0.0-1
(Arch);6.0.0-1
(Ubuntu Bionic) - Nodejs:
12.20.0-1
(Arch);10.19.0
(Ubuntu Bionic) - Wabt:
1.0.20-1
(Arch)
You can see the versions that are being used in your environment with the following command:
make show-versions
We have managed to crash the Clang compiler while programming this
project. The code is at the clang-crash
branch. Maybe I'll try to open a bug
report later. :P