It does not matter how slowly you go as long as you do not stop.
--Your friends at LectureNotes

Lab Manual for Compiler Design - CD by JNTU Heroes

  • Compiler Design - CD
  • Practical
  • Jawaharlal Nehru Technological University Anantapur (JNTU) College of Engineering (CEP), Pulivendula, Pulivendula, Andhra Pradesh, India - JNTUACEP
  • 35 Offline Downloads
  • Uploaded 1 year ago
Jntu Heroes
Jntu Heroes
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1


Text from page-2

COMPUTER SCIENCE AND ENGINEERING Program Outcomes PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 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 PSO1 PSO2 PSO3 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.

Text from page-3

COMPILER DESIGN LAB SYLLABUS Sl. No. 1 List of Experiments Page No. 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 length to some reasonable value. Simulate the same in C language. 1 * Write a C program to identify whether a given line is a comment or not. 4 *Write a C program to recognize strings under 'a', 'a*b+', 'abb'. 5 *Write a C program to test whether a given identifier is valid or not. 8 *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 tools. 11 7 Write a C program for implementing the functionalities of predictive parser for the mini language specified in Note 1. 13 8 a) *Write a C program for constructing of LL (1) parsing. b) *Write a C program for constructing recursive descent parsing. 17 Write a C program to implement LALR parsing. 24 2 3 4 5 9 10 11 12 a) *Write a C program to implement operator precedence parsing. b) *Write a C program to implement Program semantic rules to calculate the expression that takes an expression with digits, + and * and computes the value. Convert the BNF rules into Yacc form and write code to generate abstract syntax tree for the mini language specified in Note 1. Write a C program to generate machine code from abstract syntax tree generated by the parser. The instruction set specified in Note 2 may be considered as the target code. *Content beyond the University prescribed syllabi 32 39 44

Text from page-4

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. <program>::=<block> <block>::={<variable definition><slist>} |{<slist>} <variabledefinition>::=int <vardeflist> <vardec>::=<identifier>|<identifier>[<constant>] <slist>::=<statement>|<statement>;<slist> <statement>::=<assignment>|<ifstament>|<whilestatement> |<block>|<printstament>|<empty> <assignment>::=<identifier>=<expression> |<identifier>[<expression>]=<expression> <if statement>::=if<bexpression>then<slist>else<slist>endif |if<bexpression>then<slisi>endif <whilestatement>::=while<bexpreession>do<slisi>enddo <printstatement>:;=print(<expression>) <expression>::=<expression>::=<expression><addingop><term>|<term>|<addingop> <term> <bexprssion>::=<expression><relop><expression> <relop>::=<|<=|==|>=|>|!= <addingop>::=+|<term>::=<term><multop><factor>|<factor> <Multop>::=*|/ <factor>::=<constant>|<identifier>|<identifier>[<expression>] |(<expression>) <constant>::=<digit>|<digit><constant>

Lecture Notes