Cs704Pc: Compiler Design Lab B.Tech. IV Year I Sem. L T P C 0 0 2 1 Prerequisites: Co-Requisites
Cs704Pc: Compiler Design Lab B.Tech. IV Year I Sem. L T P C 0 0 2 1 Prerequisites: Co-Requisites
Prerequisites:
1. A Course on “Object Oriented Programming through Java”.
Co-requisites:
1. A course on “Web Technologies”.
Course Objectives:
• To understand the various phases in the design of a compiler.
• To understand the design of top-down and bottom-up parsers.
• To understand syntax directed translation schemes.
• To introduce lex and yacc tools.
Course Outcomes:
• Design, develop, and implement a compiler for any language.
• Use lex and yacc tools for developing a scanner and a parser.
• Design and implement LL and LR parsers.
List of Experiments:
1. Implementation of symbol table.
2. Develop a lexical analyzer to recognize a few patterns inc (ex. Identifiers, constants,
comments, operators etc.)
3. Implementation of lexical analyzer using lex tool.
4. Generate yacc specification for a few syntactic categories.
a. Program to recognize a valid arithmetic expression that uses operator +,-, * and /.
b. Program to recognize a valid variable which starts with a letter followed by any
number of letter or digits.
c. Implementation of calculator using lex and yacc.
5. Convert the bnf rules into yacc form and write code to generate abstract syntax tree.
6. Implement type checking.
7. Implement any one storage allocation strategies (heap, stack, static).
8. Write a lex program to count the number of words and number of lines in a given file or
program.
9. Write a ‘C’ program to implement lexical analyzer using c program.
10. Write recursive descent parser for the grammar:
E→E+T
E→T
T→T*F
T→F
F→ (E)/id.
11. Write recursive descent parser for the grammar:
S→ (L)
S→a
L→L,S
L→S
12. Write a C program to calculate first function for the grammar:
E→E+T
E→T
T→T*F
T→F
F→ (E)/id
13. Write a YACC program to implement a top down parser for the given grammar.
14. Write a YACC program to evaluate algebraic expression.
TEXT BOOK:
1. Compilers: Principles, Techniques and Tools, Second Edition, Alfred V. Aho, Monica S.
Lam, Ravi Sethi, Jeffry D. Ullman.
REFERENCE BOOKS:
1. Lex & Yacc – John R. Levine, Tony Mason, Doug Brown, O’reilly.
2. Compiler Construction, Louden, Thomson.