Skip to content

Simple compiler from Latte (statically typed language with object-based programming) to x86 GAS assembly.

License

Notifications You must be signed in to change notification settings

jul3x/LatteCompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LatteCompiler

Simple compiler from Latte (statically typed language with object-based programming) to x86 GAS assembly.
Second task of Compilers Construction course at MIMUW.

Language

Latte is a statically typed language with syntax and semantics very similar to Java.
Non-context grammar of this language is described in src/Latte.cf file (BNF format).
This version of latc_x86 supports arrays, structs, object inheritance and methods (without virtual methods).

Features

  • computation of trivial arithmetical expressions in compilation time
  • computation of trivial boolean expressions in compilation time
  • postprocessing: removal of redundant code (push/pop and pop/push sequences)
  • postprocessing: removal of not reachable code (after ret)

Used tools

  • BNFC 2.8 for compiler front-end generating.

Dependencies

Dependencies of parser and lexer:

  • bison
  • flex

C++:

  • gcc 9
  • ld 2.31
  • make

Compilation

Type make in main directory of repository to create executable - latc_x86.

Usage

  • ./latc_x86 foo/bar/in.lat # to compile in.lat file in foo/bar directory

generates file in.s and executable in in foo/bar directory.

  • ./run_tests.sh

runs every test in tests directory and checks if compiled code produces desired output.

Repository structure

  • LatteCompiler
    • src - contains source code of project
    • lib - contains runtime.o and runtime.s - files with definitions of library functions of Latte language written in GAS x86. Library functions are using functions from libc - they are provided in other files in this directory.
    • tests - contains *.lat, *.input and *.output files for tests
      • bad - semantic or syntax errors that compiler should recognise
      • good - good code with appropriate desired output
      • extensions - good code for arrays, structs and objects

About

Simple compiler from Latte (statically typed language with object-based programming) to x86 GAS assembly.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages