Skip to content

This repo contains the lab programs for the subject Compiler design(21CS63) for RVCE 6th students

Notifications You must be signed in to change notification settings

RohithgowdaM/RVCE-6th-sem-CD-lab-programs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RVCE 6th Sem Compiler Design Programs

RV College of Engineering, Bengaluru

Compiler Design(21CS63)

![Lab Programs for CIE and SEE](https://docs.google.com/document/d/1sYfEx-RTlhu14UrSVViqbGywJfuFdXIo/edit)


  1. Program 1: 
    1. Write a LEX program to count number of words, lines, characters and whitespaces in a given paragraph.
    2. Write a YACC program to recognize strings of the form a^nb^(n+m)c^m, n,m>=0.
  2. Program 2:
    1. Write a LEX program to count number of Positive and Negative integers and Positive & Negative fractions.
    2. Write a YACC program to validate and evaluate a simple expression involving operators +,- , * and /.
  3. Program 3:
    1. 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.
    2. Write a YACC program to recognize a nested (minimum3levels)FOR loop statement for C language.
  4. Program 4:
    1. Write a LEX program to recognize and count the number of identifiers, operators and keywords in a given input file.
    2. Write a YACC program to recognize nested IF control statements (C language) and display the number of levels of nesting.
  5. 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;
  6. Program 6: YACC program that reads the C statements for an input file and converts them in quadruple three address intermediate code.
  7. Program 7: Write a YACC program that identifies the Function Definition of C language.
  8. Program 8: Write a YACC program that generates Assembly language (Target) Code for valid Arithmetic Expression.

LLVM Programs

Program 6

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

Program 7

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

Program 8

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

About

This repo contains the lab programs for the subject Compiler design(21CS63) for RVCE 6th students

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published