[SOLVED] CCUCD - Compiler Design - Project 2 Parser

30.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (1 vote)

The goal of our project this semester is to develop a prototype C compiler. This is done by compiling C programs into processors such as x86, MIPS, ARM, or pseudo assemblies. In this class we will use Java assembly code (Jasmin, http://jasmin.sourceforge.net/) as the target codes. The project is divided into several parts including language definition, lexical analyzer, C-grammar, symbol table handlings, parser, and code generation. In the project 2, you will need to decide the set of language features you want to support in your compiler, and write the syntax analyzer.

 

Instead of generating codes, you will only need to output grammar rules in the code generator part to test whether the grammar is correctly passed. An example code may look like:

program: VOID ID ‘(‘ ‘)’ ‘{‘ declarations stmts ‘}’

{ if (TRACEON)

System.out.println(“program: VOID ID ( ) { declarations stmts }”);}

declarations: type ID ‘;’ declarations

{ if (TRACEON)

System.out.println(“declarations: type ID ; declarations”); } …

 

You can find a demo C grammar in this link:

http://www.antlr.org/download/examplesv3.tar.gz.

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.