Skip to content

kandrio/Tony-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tony-Compiler

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.

Dependencies:

  • 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 the tony bash script)

Run a Tony Program (tony 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 the tony 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 from stdin and printing the final machine code in stdout.
    • -i is for reading the Tony program from stdin and printing the LLVM IR to stdout.
    • -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.

Manually Compile a Tony Program (tonyc executable)

  • 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 called out.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.

Run Tests

  • 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

About

A compiler for Tony language...obviously.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published