JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
CS605PC: COMPILER DESIGN LAB
B.Tech III Year II Semester (R18)
Prerequisites
1. A Course on “Objected Oriented Programming through Java” Co-requisites
1. A course on “Web Technologies”
Course Objectives
1. To provide hands-on experience on web technologies
2. To develop client-server application using web technologies
3. To introduce server-side programming with Java servlets and JSP
4. To understand the various phases in the design of a compiler.
5. To understand the design of top-down and bottom-up parsers.
6. To understand syntax directed translation schemes.
7. To introduce lex and yacc tools.
Course Outcomes
1. Design and develop interactive and dynamic web applications using HTML, CSS, JavaScript and XML
2. Apply client-server principles to develop scalable and enterprise web applications.
3. Ability to design, develop, and implement a compiler for any language.
4. Able to use lex and yacc tools for developing a scanner and a parser.
5. Able to design and implement LL and LR parsers.
List of Experiments
Compiler Design Experiments
1. Write a LEX Program to scan reserved word & Identifiers of C Language
2. Implement Predictive Parsing algorithm
3. Write a C program to generate three address code.
4. Implement SLR(1) Parsing algorithm
5. Design LALR bottom up parser for the given language <program> ::= <block> <block> ::= { <variabledefinition> <slist> } | { <slist> } <variabledefinition> ::= int <vardeflist> ; <vardeflist> ::= <vardec> | <vardec> , <vardeflist> <vardec> ::= <identifier> | <identifier> [ <constant> ] <slist> ::= <statement> | <statement> ; <slist> <statement> ::= <assignment> | <ifstatement> | <whilestatement> | <block> | <printstatement> | <empty> <assignment> ::= <identifier> = <expression> | <identifier> [ <expression> ] = <expression> <ifstatement> ::= if <bexpression> then <slist> else <slist> endif | if <bexpression> then <slist> endif <whilestatement> ::= while <bexpression> do <slist> enddo <printstatement> ::= print ( <expression> ) <expression> ::= <expression> <addingop> <term> | <term> | <addingop> <term> <bexpression> ::= <expression> <relop> <expression> <relop> ::= < | <= | == | >= | > | != R18 B.TECH CSE III YEAR <addingop> ::= + | - <term> ::= <term> <multop> <factor> | <factor> <multop> ::= * | / <factor> ::= <constant> | <identifier> | <identifier> [ <expression>] | ( <expression> ) <constant> ::= <digit> | <digit> <constant> <identifier> ::= <identifier> <letterordigit> | <letter> <letterordigit> ::= <letter> | <digit> <letter> ::= a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z <digit> ::= 0|1|2|3|4|5|6|7|8|9 <empty> has the obvious meaning Comments (zero or more characters enclosed between the standard C/Java-style comment brackets /*...*/) can be inserted. The language has rudimentary support for 1-dimensional arrays. The declaration int a[3] declares an array of three elements, referenced as a[0], a[1] and a[2]. Note also that you should worry about the scoping of names. A simple program written in this language is: { int a[3],t1,t2; t1=2; a[0]=1; a[1]=2; a[t1]=3; t2=-(a[2]+t1*6)/(a[2]-t1); if t2>5 then print(t2); else { int t3; t3=99; t2=-25; print(-t1+t2*t3); /* this is a comment on 2 lines */ } endif } R18 B.TECH CSE III YEAR