A compiler for the Tony language... This is part of the Compilers course, at NTUA-ECE. To get a basic idea of how a Tony program looks, navigate through the Tony-Compiler/programs/correct
directory.
The Tony Compiler was developed and tested in a Linux-Ubuntu environment.
- flex=
2.6.4-6
- bison=
2:3.0.4.dfsg-1build1
- libgc-dev=
1:7.4.2-8ubuntu1
- clang-10
- llvm-10
- python>=
3.7.5
(for running tests and thetony
bash script)
-
Change directories to the folder of the project:
cd <your-base-dir>/Tony-Compiler
-
Run:
make tonyc
to create the./tonyc
executable. -
Run:
chmod +x tony
so you can run thetony
script. -
Run:
./tony <tony-program>.tony
. A<tony-program>.out
file is produced in the directory of your Tony program. In the same directory, you'll also find<tony-program>.asm
and<tony-program>.imm
files with the produced assembly code and intermediate code of your program. Also the script accepts the flags-O
,-f
and-i
:-O
is for optimizations.-f
is for reading the Tony program fromstdin
and printing the final machine code instdout
.-i
is for reading the Tony program fromstdin
and printing the LLVM IR tostdout
.-h
is for help / usage instructions.
So, in this case you can run:
./tony -O -f -i <tony-program>.tony
. -
Run your program executable:
./<tony-program>.out
.
- Change directories to the folder of the project:
cd <your-base-dir>/Tony-Compiler
- Run:
make tonyc
to create the./tonyc
executable. - Run:
./tonyc <tony-program>.tony
to produce the LLVM code of your program. A file calledout.ll
is created, and it contains the LLVM code. - Run:
clang-10 out.ll lib.a -o <desired-name>.out -lgc
to produce the binary executable of your program. - Run your program executable:
./<desired-name>.out
.
- Change directories to the folder of the compiler:
cd <tony-compiler-dir>
- Run:
make tonyc
to create the./tonyc
executable. - Run the tests:
python3 programs/run_tests.py