Department of Computer Science and Engineering
National Institute of technology, Silchar
Course Profile
Semester/branch: 5th Sem. CSE
Course Title: COMPILER DESIGN LAB. L T P C
Course code: CS 1315
Prerequisites: Nil 0 0 2 2
Course Coordinator: Thoudam Doren Singh
Course Overview:
This Laboratory Course will enable the students to implement the basic concepts compiler
design using tools like Lex and Yacc.
Course Outcomes:
After completing this course the students should be able to:
a) Gain knowledge about the Lex and Yacc.
b) Implement the basic concepts of compiler design using Lex and Yacc.
List of experiments
1. Write an introduction on 'lex'.
2. Write a lex program to recognize an alphabet.
3. Write a lex program to identify keywords, symbols and operators.
4. Write a lex program, which takes a C program as input, and display the list of
identifiers and operators.
5. Write a lex program to count the number of vowels and consonants in a given
sentence.
6. Write a lex program to count the number of lines, words, special characters and letters
in a program.
7. Write a lex program to count the number of comments in a C program, and then delete
the comments.
8. Program a lex program to count the number of keywords, operators, identifiers,
comments, and then delete the comments.
9. Write a yacc program to evaluate an arithmetic expression involving + , - , × , ÷ .
10. Write a yacc program to recognize nested “IF” control statements, and display the
number of level of nesting.
11. Write a yacc program to recognize a valid variable, which starts with a letter followed
by any number of digit and letter.
12. Write a yacc program to recognize strings “aaab”, “abbb”, “ab” and “a” using the
grammar an b n , where n>0 .
Reference books:
1. John Levine, Tony Mason & Doug Brown, “Lex and Yacc”, O’Reilly.1995
2. Alfred V. Aho, R. Sethi and J.D. Ullman “Compilers: principles,
techniques and tools” Addison-Wesley.
3.
Page 1 of 2
CO-PO mapping for the CS 1315:
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
CO1
CO2
Evaluation Scheme:
Assessment Weightage (%)
Attendance 5
Lab-Copy 20
Lab. Exam 50
Viva 25
Total 100
Page 2 of 2