PROJECTS - COMPILER CONSTRUCTION

Compiler: SLIC to GSTAL

SLIC to GSTAL Compiler

This was a semester long project: to create a fully functional compiler that translates SLIC programs into GSTAL. Both SLIC and GSTAL were created specifically for this project. The compiler has a fully functional front end and back end, with a clear devision between the two. However, it does not provide any code optimization. There are three main components: the lexical analyzer, syntax analyzer, and a code generator. Flex was used to create the lexical analyzer, and Bison was used to create the syntax analyzer.

 

SLIC - A Simple Language for an Instructional Compiler

SLIC is an imperative, procedural language with strong similarities to Pascal, C, Basic, and many other common high-level languages. It is designed to maximize the ease of compilation. It is not intended to be a language for production programming.

 

GSTAL - Georgetown Stack Assembly Language

The Georgetown Stack Assembly Language (GSTAL) is a interpreted stack assembly language.

 

Notes

Flex and Bison are updated versions of Lex and Yacc respectively. They are tools specifically created for writing the front end of compilers. Flex generates a lexical analyzer from a set of token definitions, and Bison generates a syntax analyzer from a context-free grammar with blocks of code inserted into the productions. For this project, lexfile.l and bisonfile.y are the input files to Flex and Bison respectively.

 

Two example SLIC programs have included, one with its corresponding GSTAL program. The given GSTAL program was compiled with the instructor's compiler, so it may not exactly match the output of the compiler given here.

 

This project has been compiled and tested using Cygwin, a Linux-like environment for Windows. Make can be used to compile this program and the makefile is given on the right.

Copyright ©2016 Tate Burns. All Rights Reserved.

TATE BURNS

Creative Thinker • Innovative Developer

CONTACT ME

tate@burnskids.com

(734) 846-2121