RV College of Engineering, Bengaluru
Compiler Design(21CS63)
![Lab Programs for CIE and SEE](https://docs.google.com/document/d/1sYfEx-RTlhu14UrSVViqbGywJfuFdXIo/edit)- Program 1:
- Write a LEX program to count number of words, lines, characters and whitespaces in a given paragraph.
- Write a YACC program to recognize strings of the form a^nb^(n+m)c^m, n,m>=0.
- Program 2:
- Write a LEX program to count number of Positive and Negative integers and Positive & Negative fractions.
- Write a YACC program to validate and evaluate a simple expression involving operators +,- , * and /.
- Program 3:
- Write a LEX program to count the number of comment lines in a C Program. Also eliminate them and copy that program into a separate file.
- Write a YACC program to recognize a nested (minimum3levels)FOR loop statement for C language.
- Program 4:
- Write a LEX program to recognize and count the number of identifiers, operators and keywords in a given input file.
- Write a YACC program to recognize nested IF control statements (C language) and display the number of levels of nesting.
- Program 5: Write a YACC program to recognize Declaration statement (C language) and display the number variables declared . Variable can be any basic data type or array type Example int a[10],a,b,c;
- Program 6: YACC program that reads the C statements for an input file and converts them in quadruple three address intermediate code.
- Program 7: Write a YACC program that identifies the Function Definition of C language.
- Program 8: Write a YACC program that generates Assembly language (Target) Code for valid Arithmetic Expression.
This program is to print the unoptimised and optimised code for a bubble sort code
# to print the unoptimised assembly code
clang filename.c -S -emit-llvm -o filename
# to print the optimised assembly code
clang filename.c -S -emit-llvm -o filename -O3
This program is to print the unoptimised and optimised code for a binary search code
# to print the unoptimised assembly code
clang filename.c -S -emit-llvm -o filename
# to print the optimised assembly code
clang filename.c -S -emit-llvm -o filename -O3
this is about loop unrolling
# comment out the unroll pragma to see the difference
clang filename.c -S -emit-llvm -o filename
# for unrolled optimisation
clang filename.c -S -emit-llvm -o filename -O3