Skip to content

muhummadPatel/compilers_assignment2

Repository files navigation

##Compilers: Assignment 2: Ula compiler backend

Author : Muhummad Yunus Patel
Student# : PTLMUH006
Date : 29-September-2015

###Description: This assignment required the creation of the semantic analyser, error handling, and code generator modules for a made up language called ula (Unconventional Language). The modules were written in Python using the PLY library (wrapper for Lex and Yacc).

The semantic analyser checks that the program is semantically correct. The semantic analyser takes in the abstract syntax tree representation of the program that was generated by the parser module. It makes use of a symbol table to keep track of the active variables and ensures that variables aren't used before being declared. It also checks for type errors and other such inconsistencies in the input program. The semantic analyser outputs a compact form of the abstract syntax tree to the code generator module.

The code generator module takes in the compact abstract syntax tree representation of the program and first converts it to an intermediate representation format (IR code) and then converts it to machine code that can be run on the host machine. This is essentially the "back end" of the compiler. The machine code output from this stage will be machine code that can run on the architecture on which it was compiled.

Every module takes care of it's own error handling. If an error occurs in a specific module, a suitable error message is output and the compilation process is terminated. (We don't want to continue trying to compile a malformed program)

Assignment 1 and 2 together make up a complete compiler for the trivial ula language.

###Usage:

  • See assignment spec pdf for usage instructions.
  • Ula sample programs provided as part of this repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published