12

Click here to load reader

Compiler Design Lab Manual 7th

Embed Size (px)

DESCRIPTION

Compiler Design Lab Manual Seventh Semester Anna university

Citation preview

Page 1: Compiler Design Lab Manual 7th

MERI COLLEGE OF ENGGINEERING AND TECHNOLOGY, SAMPLA

Compiler Design Lab Lab Manual

Page 2: Compiler Design Lab Manual 7th

IndexS. no. Contents

1 Syllabus as per M. D. University

2 Hardware and Software requirements

3 Rationale behind CD LAB

4 List of Programs

5 Lab Plan

6 List of Projects

7 Project plan

8 Project allocation table

9Practical details:

AlgorithmProgram code

Output

Page 3: Compiler Design Lab Manual 7th

Syllabus as per M. D. UniversitySession: 2013-2014

B.TECH (CSE) SEMESTER VII

Subject: COMPILER DESIGN LABSubject Code: CSE-407 E

1 .Practice of Lex/Yacc of Compiler writing.

2. Write a program to check whether a string belongs to the grammar or not.

3. Write a program to generate a parse tree.

4. Write a program to find leading terminals.

5. Write a program to find trailing terminals.

6. Write a program to compute FIRST of non-terminals.

7. Write a program to compute FOLLOW of non-terminals.

8. Write a program to check whether a grammar is left recursive and remove left recursion.

9. Write a program to remove left factoring.

10. Write a program to check whether a grammar is Operator precedent.

11. To show all the operations of a stack.

12. To show various operations i.e read,write and modify in a text file.

Note : At least 10 programs are required to be developed in the semester.

Page 4: Compiler Design Lab Manual 7th

Hardware and software requirements

Hardware Requirements:

Processsor: Pentium I RAM: Hard Disk

128MB 40 GB

Floppy Drive 1.44MB

Software Requirements:

Lex and Yacc tools.(A Linux Utility) Language: C/C++

System Configuration on which lab is conducted

Processor: RAM HDD FDD Monitor Keyboard Operating System Windows XP Mouse Scroll

PIV(1.8Ghz) 256MB 40GB 1.44MB

14''Color Multimedia

Page 5: Compiler Design Lab Manual 7th

Rationale behind CD LAB

Compiler is a System Software that converts High level language to low level lang. We human beings can't program in machine lang (low level lang.) understood by Computers so we prog. In high level lang and compiler is the software which bridges the gab between user and computer.

It's a very complicated piece of software which took 18 man years to build first compiler To build this S/w it is divided into six phases which are

1) Lexical Analysis 2) Syntax Analysis 3) Semantic Analysis 4) Intermediate Code Generation 5) Code Optimization 6) Code Generation.

Page 6: Compiler Design Lab Manual 7th

Subject: COMPILER DESIGN LABSubject Code: CSE-407 E

Section ASession : 2013-14 Total No of Labs : 14

List of Programs to be executed in lab

S. No. Programs List

1 STUDY OF LEX & YACC TOOLS

2 PROGRAM TO CHECK WHEATHER A STRING BELONGS TO A GRAMMAR OR NOT.

3 PROGRAM IS TO CALCULATE LEADING FOR ALL THE NON-TERMINALS OF THE GIVEN GRAMMAR

4 PROGRAM IS TO CALCULATE TRAILING FOR ALL THE NON-TERMINALS OF THE GIVEN GRAMMMAR

5 PROGRAM FOR COMPUTATION OF FIRST

6 PROGRAM TO FIND THE NUMBER OF WHITESPACES AND NEWLINES CHARACTERS

7 TO IMPLEMENT STACK USING ARRAY

Page 7: Compiler Design Lab Manual 7th

8 TO IMPLEMENT STACK AS LINKED LIST

9 ALGORITHM TO IDENTIFY WHETHER A GIVEN STRING IS AN IDENTIFIER OR NOT

10 THIS PROGRAM IS TO FIND OUT WHETHER A GIVEN STRING IS A IDENTIFIER OR NOT

11 ALGORITHM TO CHECK WHETHER A STRING IS A KEYWORD OR NOT

12 PROGRAM TO FIND WHETHER STRING IS A KEYWORD OR NOT

13 ALGORITHM TO FIND WHETHER A STRING IS A CONSTANT OR NOT

14 PROGRAM TO FIND WHETHER THE STRING IS CONSTANT OR NOT

Subject: COMPILER DESIGN LABSubject Code: CSE-407 E

Section B

List of Projects to be developed in Lab

1. To develop basic compiler for arithmetic expressions in C language.2. To develop basic compiler for logical expressions in C language.3. To develop basic compiler for arithmetic expressions in C++ language.4. To develop basic compiler for logical expressions in C++ language.5. To develop basic compiler for logical expressions in JAVA language.6. To develop basic compiler for arithmetic expressions in JAVA language.7. To develop basic shell script interpreter for shell scripting.8. To develop basic compiler for case statements in C++ language.9. To develop basic compiler for case statements in C language.10. To develop basic compiler for case statements in Java language.

Page 8: Compiler Design Lab Manual 7th

Subject: COMPILER DESIGN LABSubject Code: CSE-407 E

PROJECT PLAN

Project work will pass through given stages:

Stages Project PlanProject design as a whole August Fourth WeekModular design September First WeekAlgorithm September Second WeekCoding September Third Week – October

Second WeekError Removal/Handling October Third WeekTesting October Fourth WeekSubmission November First Week

Page 9: Compiler Design Lab Manual 7th

Subject: COMPILER DESIGN LABSubject Code: CSE-407 E

Section - C

Project Allocation Table

Project No.

Student Roll-No

1 1-42 5-83 9-124 13-165 17-206 21-247 25-288 29-329 33-3610 37– last rollno

Page 10: Compiler Design Lab Manual 7th