This repository contains solutions to various lab exercises in compiler construction. It also includes additional practice questions and exam solutions.
- PDF file with all the questions and codes: CC LAB ANSWERS.pdf.
- Q1: LEX program to recognize operators, numbers, newline & mystery character
- Q2: LEX program to print the number of words, characters and lines in a given input
- Q3: Modify the above LEX program (Q2) so that a word and its characters are counted only if its length is greater than or equal to 6
- Q4: LEX program to print if the input is an odd number or an even number along with its length
- Q1: LEX program to get a binary input and print whether the given input is a power of two or not
- Q2: LEX program to insert line numbers to a file
- Q3: LEX program to save the contents of an input file excluding comment lines to another file
- Q4: LEX program that would take a BITS student's roll number as input and prints the details of the student based on that
- Q1: Write a LEX program to: 1. take file input from command line 2. identfier, string, keywords, delimiter, identify and print
- Q2: Read from file instruction.c and concatenate the strings string 1 and string 2 then check if it's a palindrome or not
- Q3: Get two numbers as input. Reverse the second number and check if it's equal to the first number. Handle incorrect input and display appropriate message
- Q1: Understand the working of LEX and YACC using a simple calculator application
- Q2: Modify Q1 program to take care of associativity of the operators using directives in YACC.
- Q3: Extend the calculator to incorporate some new functionality.
- Q4: Modify the grammar to allow single-character variables to be specified in assignment statements.
- Q1: Write the LEX and YACC source to recognize the following general template
- Q2: Allow declaration statements inside the program body.
- Q3: Allow declaration statements to be followed by program statements inside the program body.
- Q4: Modify your lex program so as to let the programmer have uppercase letters A to Z together with digits 0 to 9 and underscore character in variable names.