Lolcode execution
Compiler Design and Construction COSC 5353
Project Instructions - LOLCODE
In this project, you will develop a minimalistic compiler for a procedural programming language. You will build on the work you did in Assignment 1 and will create compiler that accepts a nontrivial subset of LOLCODE programming language: http://www.lolcode.org/
This assignment is worth 200 points, and covers two areas: syntax-directed translation, and code generation. There are 2 stages of the project, each worth 100 points:
1) Grammar and intermediate representation. Language specification is described here:
https://github.com/justinmeza/lolcode-spec/blob/master/v1.2/lolcode-spec-v1.2.md
a. Using your LOLCALC Bison grammar specification as a starting point, extend the grammar to properly recognize valid LOLCODE programs. Minor deviations are OK (eg., I would not deduct points if you do not handle comments). The grammar should be complete enough that your language subset is (1) proper LOLCODE and (2) sufficient to write nontrivial programs
b. Create a data structure for a rudimentary Abstract Syntax Tree (AST), or possibly another intermediate representation, and add code to your program to construct it. At this point, do not worry too much about having all the attributes for subsequent code generation.
c. Submit your project to Blackboard. Due date is November 8, 2021
2. Extend your project to generate working low-level code for programs. Code should be capable of execution directly or in a simulator. Due date: November 30, 2021
For syntax-directed translation, pick an intermediate representation that you see fit (such as an Abstract Syntax Tree). For code generation, output should be into a real low-level language: MIPS assembly code that run on the SPIM simulator; JVM code, LLVM assembly, or Knuth’s MIX code using appropriate emulator. Translations to another high-level language (C, JavaScript, etc.) won’t be accepted.
Submissions will be graded on how complete your implementation is. Approximate points allocation is (for info purposes only):
Accept relevant syntax and construct valid AST or another IR – 40 %.
Construct and output a valid Symbol Table – 30 %.
Generate code for variable declarations (NUMBER type) – 20 %
Generate code for expressions – 20 %
Generate code for Conditional statements – 20 %
Generate code for loops – 20 %.
Generate code for input/output (VISIBLE/GIMMEH) and string constants – 20 %.
Generate code for procedures – 20 %
Generate code for additional language features (YARN type, TROOF type, type casting, local variable scope etc.) – 10 %. each.
Optimizations – 10-50 %.
Clear report accompanying submission – 20 %.
Features above the minimum workable language subset can earn points above 100%; these points are extra credit.
Note: you should work on assignment on your own. Sharing code with other students is not allowed. Using code from the Internet is allowed and encouraged; however, you must show your significant efforts to build upon the code you downloaded, respect copyright (if code is not in public domain), and give proper referencing.
Resources:
1. LOLCODE: http://www.lolcode.org/
2. Run LOLCODE online: https://www.tutorialspoint.com/execute_lolcode_online.php
3. FLEX reference: ftp://ftp.gnu.org/old-gnu/Manuals/flex-2.5.4/html_mono/flex.html
4. BISON reference: https://www.gnu.org/software/bison/manual/
A book on BISON and FLEX is available at http://web.iitd.ac.in/~sumeet/flex__bison.pdf
5. Using SPIM with Modern Compiler Implementation - https://www.cs.princeton.edu/~appel/modern/spim/ .
6. Assemblers, Linkers, and the SPIM simulator – on Blackboard
7. https://busy.org/@drifter1 (scroll down to see his “Writing a simple Compiler on my own” tutorial series, which links to GitHub with code samples).