COMPILER DESIGN

COMPILER DESIGN

LAB MANUAL

Subject Code: Regulations: Class:

A50587 R13 ? JNTUH III Year I Semester (CSE)

Prepared By

Ms. E Uma Shankari Assistant Professor, CSE

Ms. G Geetha Assistant Professor, CSE

Department of Computer Science & Engineering

INSTITUTE OF AERONAUTICAL ENGINEERING

Dundigal ? 500 043, Hyderabad

INSTITUTE OF AERONAUTICAL ENGINEERING

Dundigal, Hyderabad - 500 043

COMPUTER SCIENCE AND ENGINEERING

PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12

PSO1 PSO2 PSO3

Program Outcomes

Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an engineering specialization to the solution of complex engineering problems. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences. Design/development of solutions: Design solutions for complex engineering problems and design system components or processes that meet the specified needs with appropriate consideration for the public health and safety, and the cultural, societal, and environmental considerations. Conduct investigations of complex problems: Use research-based knowledge and research methods including design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusions. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools including prediction and modeling to complex engineering activities with an understanding of the limitations. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice. Environment and sustainability: Understand the impact of the professional engineering solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams, and in multidisciplinary settings. Communication: Communicate effectively on complex engineering activities with the engineering community and with society at large, such as, being able to comprehend and write effective reports and design documentation, make effective presentations, and give and receive clear instructions. Project management and finance: Demonstrate knowledge and understanding of the engineering and management principles and apply these to one's own work, as a member and leader in a team, to manage projects and in multidisciplinary environments. Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent and life-long learning in the broadest context of technological change.

Program Specific Outcomes

Professional Skills: The ability to research, understand and implement computer programs in the areas related to algorithms, system software, multimedia, web design, big data analytics, and networking for efficient analysis and design of computer-based systems of varying complexity. Problem-Solving Skills: The ability to apply standard practices and strategies in software project development using open-ended programming environments to deliver a quality product for business success. Successful Career and Entrepreneurship: The ability to employ modern computer languages, environments, and platforms in creating innovative career paths, to be an entrepreneur, and a zest for higher studies.

COMPILER DESIGN LAB SYLLABUS

Sl. No.

List of Experiments

Page No.

1

Design a lexical analyzer for given language and the lexical analyzer should ignore

redundant spaces, tabs and new lines. It should also ignore comments. Although the

syntax specification states that identifiers can be arbitrarily long, you may restrict the

1

length to some reasonable value. Simulate the same in C language.

2

* Write a C program to identify whether a given line is a comment or not.

4

3

*Write a C program to recognize strings under 'a', 'a*b+', 'abb'.

5

4

*Write a C program to test whether a given identifier is valid or not.

8

5

*Write a C program to simulate lexical analyzer for validating operators.

9

6

Implement the lexical analyzer using JLex, flex or other lexical analyzer generating

11

tools.

7

Write a C program for implementing the functionalities of predictive parser for the mini

13

language specified in Note 1.

8

a) *Write a C program for constructing of LL (1) parsing.

17

b) *Write a C program for constructing recursive descent parsing.

9

Write a C program to implement LALR parsing.

24

10 a) *Write a C program to implement operator precedence parsing.

b) *Write a C program to implement Program semantic rules to

calculate the

32

expression that takes an expression with digits, + and * and computes the value.

11 Convert the BNF rules into Yacc form and write code to generate abstract syntax tree 39

for the mini language specified in Note 1.

12 Write a C program to generate machine code from abstract syntax tree generated by the

44

parser. The instruction set specified in Note 2 may be considered as the target code.

*Content beyond the University prescribed syllabi

Note 1: A simple language written in this language is

{int a[3],t1,t2; T1=2; A[0]=1;a[1]=2;a[t]=3; T2=-( a[2]+t1*6)/(a[2]-t1); If t2>5then Print(t2) Else{ Int t3; T3=99; T2=25; Print(-t1+t2*t3);/*this is a comment on 2 lines*/ }endif } Comments(zero or more characters enclosed between the standard C/JAVA Style comment brackets/*...*/)can be inserted .The language has rudimentary support for1-dimenstional array,the declaration int a[3] declares an array of three elements,referenced as a[0],a[1] and a[2].Note also you should worry about the scopping of names.

Note 2:

Consider the following mini language, a simple procedural high ?level language, only operating on integer data, with a syntax looking vaguely like a simple C crossed with pascal. The syntax of the language is defined by the following grammar.

::= ::={} |{} ::=int ::=|[] ::=|; ::=|| ||| ::== |[]= ::=ifthenelseendif |ifthenendif ::=whiledoenddo :;=print() ::=::=|| ::= ::=|!= ::=+|::=| ::=*|/ ::=||[] |() ::=|

::=| ::=| :;=a|b|c|d|e|f|g|h|I|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z ::=0|1|2|3|4|5|^|7|8|9 ::=has the obvious meaning

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download