Compiler Consrtuction TE CSE-II Department of Computer Science
& Engg.
Roll No:
Exam Seat No:
Savitribai Phule Shikshan Prasarak MandalsN B NAVALE SINHGAD
COLLEGE OF ENGINEERING, SOLAPUR
Computer Science & Engineering
LABORATORY MANUAL
In the subject of
Compiler Construction
For Academic Year 2014-15
Savitribai Phule Shikshan Prasarak MandalsN B NAVALE SINHGAD
COLLEGE OF ENGINEERING, SOLAPUR
CERTIFICATE
This is to certify that, Mr/Msof Class T.E. CSE Division,Roll
Nohas completed all the practical work in the subject of
satisfactory in the department of Computer Science and Engineering
as prescribed by Solapur University, Solapur, in the semester-II of
academic year 2014-15.
Date:
Subject Incharge Head of Department Principal
Name of SubjectINDEXSR. NO.TITLE OF THE EXPERIMENTPAGE NO.Date
of PerformanceDate of EvaluationMarks (10)Sign
1
2
3
4
5
6
7
8
9
10
Total Marks:- Marks out of 10:-
N B Navale Sinhgad College of EngineeringDepartment of Computer
Science& Engineering Sub: - Computer Construction
Experiment No. 1
Experiment NameDesign and Implementation of Lexical Analyzer
Experiment Performed Date -
Signature of In-charge
Experiment Submitted Date -
EXP. No. 1Date: Implementation of Lexical Analyzer Aim: To
separate the tokens from the given source program Theory: Q.1 Draw
and explain the diagram illustrating the working of Lexical
analyzer.
Algorithm: Step 1: Declare the necessary variables. Step 2:
Declare an array and store the keywords in that array Step 3: Open
the input file in read open Step 4: read the string from the file
till the end of file. If the first character in the string is #
then print that string as header file If the string matches with
any of the keywords print that string is a Keyword. If the string
matches with operator and special symbols print the corresponding
message. If the string is not a keyword then print that as an
identifier. Input: #include void main() { int a; double b; char c;
printf("%d %b %c",a,b,c); } Output: #include header file void
Keyword main Keyword ( Left Parenthesis ) Right Parenthesis { Open
Brace int Keyword a Identifier ; Semicolon b Identifier ; Semicolon
char Keyword c Identifier ; Semicolon ( Left Parenthesis %c Control
string , Comma a Identifier , Comma a Identifier , Comma ) Right
Parenthesis ; Semicolon } Close Brace
CONCLUSION:
Note:- Student should attach the printout of Program and
Output.
N B Navale Sinhgad College of EngineeringDepartment of Computer
Science& Engineering Sub: - Compiler Construction
Experiment No. 3
Experiment NameTo implement elimination of Left Recursion in the
CFG
Experiment Performed Date -
Signature of In-charge
Experiment Submitted Date -
EXP. No. Date: Elimination of Left Recursion in the CFG Aim: -
Write a C Program for elimination of left recursion in a given
context free grammar THEORY:- Q.1 Define and explain left recursive
grammar. What is the disadvantage of using left recursive grammar
in top-down parsing? Q.2 Write the algorithm for the elimination of
left recursion in a given context free grammar. Explain this
algorithm with example.
CONCLUSION:
Note: - Student should attach the printout of Program and
Output.
N B Navale Sinhgad College of EngineeringDepartment of Computer
Science& Engineering Sub: - Compiler Construction
Experiment No. 4
Experiment NameTo design and implement Recursive Descent
Parser
Experiment Performed Date -
Signature of In-charge
Experiment Submitted Date -
EXP. No. Date: Recursive-descent Parser Aim: Write a C program
to implement the recursive-descent Parser.THEORY: Q.1 Explain in
detail the recursive-descent parser. Q.2 Explain with example
top-down Parsing with backtracking.
CONCLUSION:
Note:- Student should attach the printout of Program and
Output.
N B Navale Sinhgad College of EngineeringDepartment of Computer
Science& Engineering Sub: - Compiler Construction
Experiment No. 5
Experiment NameTo implement Operating Precedence Parser
Experiment Performed Date -
Signature of In-charge
Experiment Submitted Date -
EXP. No. Date: Operating Precedence ParserAim: Write a C rogram
to implement Operating Precedence Parser
THEORY: Q.1 Explain in detail with example Operator precedence
parsing.
Operator Precedence Parsing Algorithm Initialize: Set ip to
point to the first symbol of w$ Repeat: Let X be the top stack
symbol, and a the symbol pointed to by ip if $ is on the top of the
stack and ip points to $ then return else Let a be the top terminal
on the stack, and b the symbol pointed to by ip if a b then repeat
pop the stack until the top stack terminal is related by