compiler design

Closed Posted Apr 30, 2014 Paid on delivery
Closed Paid on delivery

translate a program with the following grammar

PROGRAM -> VAR_SECTION BODY

VAR_SECTION -> ID_LIST ';'

ID_LIST -> id ',' ID_LIST | id

BODY -> '{' STMT_LIST '}'

STMT_LIST -> STMT STMT_LIST | STMT

STMT -> ASSIGN_STMT | PRINT_SMT | WHILE_STMT | IF_STMT | SWITCH_STMT

ASSIGN_STMT -> id '=' PRIMARY ';'

ASSIGN_STMT -> id '=' EXPR ';'

EXPR -> PRIMARY OP PRIMARY

PRIMARY -> id | num

OP -> '+' | '-' | '*' | '/'

PRINT_STMT -> print id ';'

WHILE_STMT -> 'WHILE' CONDITION BODY

IF_STMT -> 'IF' CONDITION BODY

CONDITION -> PRIMARY RELOP PRIMARY

RELOP -> '>' | '<' | '!='

SWITCH_STMT -> 'SWITCH' id '{' CASE_LIST '}'

into intermediate code aka

The input file

a = 5;

while (a > 1) {

a = a - 1;

print a;

}

print a;

generates the following output file:

a

#e1=14, #e2=3

LIT 5, 0

STO a, 0

LOD a, 0

LIT 1, 0

OPR 11, 0

JMC #e1, false

LOD a, 0

LIT 1, 0

OPR 3, 0

STO a, 0

LOD a, 0

OPR 21, 0

JMP #e2, 0

LOD a, 0

OPR 21, 0

C++ Programming

Project ID: #5877880

About the project

5 proposals Remote project Active Jun 6, 2014

5 freelancers are bidding on average $387 for this job

hbxfnzwpf

You can check my review, I have finished several compiler project, I am very familiar with this, I can send you solution in less than one day. please let me do this. I am very proficient in c, c++. I have 15 years More

$278 USD in 2 days
(141 Reviews)
7.0
szymszteinsl

Hi! I a professional C/C++/C#/Java programmer. I can do this with highest satisfaction! Best Regards, Szymszteinsl

$500 USD in 3 days
(63 Reviews)
6.7
rakib062

Hi, I am a graduate in CS with major in OS and Compiler design and working as a C++ programmer for 4+ years. I did similar project of compiler construction using Grammar and DFA/NFA. I have done lots of assignments b More

$300 USD in 7 days
(19 Reviews)
4.2
vehre

Dear Client, herewith I apply for your job "compiler design". I provide decent knowledge about grammar writing and transforming internal representations into "code". I wield ANTLR or bison/flex as you desire. Reg More

$555 USD in 3 days
(1 Review)
2.3