Translator Design CRN Test 3 Revision 1 CMSC 4173 Spring 2012

Similar documents
Translator Design CRN Course Administration CMSC 4173 Spring 2017

Translator Design CRN Course Administration CMSC 4173 Spring 2018

CSCE 531 Spring 2009 Final Exam

R10 SET a) Construct a DFA that accepts an identifier of a C programming language. b) Differentiate between NFA and DFA?

CMSC330 Fall 2016 Midterm #2 2:00pm/3:30pm

CSE 401 Midterm Exam 11/5/10

1. (a) What are the closure properties of Regular sets? Explain. (b) Briefly explain the logical phases of a compiler model. [8+8]

Compiler Construction

Midterm I (Solutions) CS164, Spring 2002

UNIT -2 LEXICAL ANALYSIS

CSE 582 Autumn 2002 Exam 11/26/02

CS 2210 Sample Midterm. 1. Determine if each of the following claims is true (T) or false (F).

ECE 468/573 Midterm 1 October 1, 2014

SYED AMMAL ENGINEERING COLLEGE (An ISO 9001:2008 Certified Institution) Dr. E.M. Abdullah Campus, Ramanathapuram

CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 20th May 2016 Time: 14:00-16:00

Compiler Design Aug 1996

Midterm Solutions COMS W4115 Programming Languages and Translators Wednesday, March 25, :10-5:25pm, 309 Havemeyer

CSE 582 Autumn 2002 Exam Sample Solution

CSCI Compiler Design

CS 164 Handout 11. Midterm Examination. There are seven questions on the exam, each worth between 10 and 20 points.

GUJARAT TECHNOLOGICAL UNIVERSITY

Chapter 3: Describing Syntax and Semantics. Introduction Formal methods of describing syntax (BNF)

Compiler Construction

Midterm I - Solution CS164, Spring 2014

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

1. [5 points each] True or False. If the question is currently open, write O or Open.

Concepts Introduced in Chapter 3. Lexical Analysis. Lexical Analysis Terms. Attributes for Tokens

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

LECTURE NOTES ON COMPILER DESIGN P a g e 2

S Y N T A X A N A L Y S I S LR

Lexical Analysis - 2

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Compilers for Modern Architectures Course Syllabus, Spring 2015

CSE 5317 Midterm Examination 4 March Solutions

Lexical Analysis. Introduction

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Torben./Egidius Mogensen. Introduction. to Compiler Design. ^ Springer

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTING DEPARTMENT OF CSE COURSE PLAN

CS 403 Compiler Construction Lecture 3 Lexical Analysis [Based on Chapter 1, 2, 3 of Aho2]

2068 (I) Attempt all questions.

UNIT III & IV. Bottom up parsing

Parsing. Handle, viable prefix, items, closures, goto s LR(k): SLR(1), LR(1), LALR(1)

DOID: A Lexical Analyzer for Understanding Mid-Level Compilation Processes

SRM UNIVERSITY FACULTY OF ENGINEERING AND TECHNOLOGY SCHOOL OF COMPUTER SCIENCE AND ENGINEERING COURSE PLAN

Roll No. :... Invigilator's Signature :. CS/B.Tech(CSE)/SEM-7/CS-701/ LANGUAGE PROCESSOR. Time Allotted : 3 Hours Full Marks : 70

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

LLparse and LRparse: Visual and Interactive Tools for Parsing

Lexical Analysis. Lexical analysis is the first phase of compilation: The file is converted from ASCII to tokens. It must be fast!

CS 536 Midterm Exam Spring 2013

1 Lexical Considerations

CST-402(T): Language Processors

CSE P 501 Exam 8/5/04

KALASALINGAM UNIVERSITY ANAND NAGAR, KRISHNAN KOIL DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING ODD SEMESTER COURSE PLAN

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

ECE 468/573 Midterm 1 September 30, 2015

Eng. Maha Talaat Page 1

CMPE 152 Compiler Design

QUESTIONS RELATED TO UNIT I, II And III

Compiler Design Overview. Compiler Design 1

Formal Languages and Compilers Lecture VI: Lexical Analysis

Chapter 2 Working with Data Types and Operators

Compilers. Computer Science 431

Lexical Analysis. Lecture 3. January 10, 2018

4. Inputting data or messages to a function is called passing data to the function.

SFU CMPT 379 Compilers Spring 2018 Milestone 1. Milestone due Friday, January 26, by 11:59 pm.

Question Bank. 10CS63:Compiler Design

CSE 401 Midterm Exam Sample Solution 2/11/15

Problem Score Max Score 1 Syntax directed translation & type

Lexical Analysis. Dragon Book Chapter 3 Formal Languages Regular Expressions Finite Automata Theory Lexical Analysis using Automata

CS 374 Fall 2014 Homework 2 Due Tuesday, September 16, 2014 at noon

This test is not formatted for your answers. Submit your answers via to:

Gujarat Technological University Sankalchand Patel College of Engineering, Visnagar B.E. Semester VII (CE) July-Nov Compiler Design (170701)

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER COMPILERS ANSWERS. Time allowed TWO hours

CS143 Handout 20 Summer 2011 July 15 th, 2011 CS143 Practice Midterm and Solution

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

Full file at

CS 411 Midterm Feb 2008

CS5363 Final Review. cs5363 1

Test I Solutions MASSACHUSETTS INSTITUTE OF TECHNOLOGY Spring Department of Electrical Engineering and Computer Science

CS415 Compilers. Lexical Analysis

CSCI 565 Compiler Design and Implementation Spring 2014

ECE573 Introduction to Compilers & Translators

MIDTERM EXAM (Solutions)

Chapter 3: Lexing and Parsing

CS Compiler Construction West Virginia fall semester 2014 August 18, 2014 syllabus 1.0

Midterms Save the Dates!

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

Dr. D.M. Akbar Hussain

COL728 Minor1 Exam Compiler Design Sem II, Answer all 5 questions Max. Marks: 20

CS308 Compiler Principles Lexical Analyzer Li Jiang

CS 314 Principles of Programming Languages

Closed Book Examination. Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Monday 26 th January 2009.

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Exam for CSE 450 (2016)

SFPL Reference Manual

Non-deterministic Finite Automata (NFA)

Full file at

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

Transcription:

Name: Student ID: E-Mail: Course CMSC 4173, Translator Design CRN: 24414, Spring, 2012 Date: Thursday, May 3, 2012 at 5:30 p.m. Instructions: 1. Type your name in the space provided. 2. Type your student identifier in the space provided. 3. Type your e-mail address in the space provided. 4. Questions requiring written answers must be answered using standard American English. 5. Answers must be coded legibly. Neatly drawn diagrams are acceptable. Text must be typewritten. Answers that cannot be read by your instructor will be given no credit. 6. You must do your own work. 7. Submit this test with your answers on this document to your instructor electronically on or before 5:30 p.m. on Thursday, May 3, 2012. Create an electronic note. 7.1. Send the note to trturner@uco.edu. 7.2. Make the subject line your CRN, hyphen, your-last-name, hyphen, your-first-name, hyphen, t03. For example, if your name is Alan Turing and you are enrolled in CRN 24414, the subject line of your note is 24414-Turing-Alan-t03. 7.3. Attach this document completed and renamed to your-crn, hyphen, your-last-name, hyphen, your-first-name, hyphen, t03.doc. For example, if your name is Alan Turing and you are enrolled in CRN 24414, the subject line of your note is 24414-Turing-Alan-t03.docx. Scoring: 1. The table below lists the number of points available for each problem and the total number of points that can be earned on this test. 2. You can earn up to 360 points on the test. You need only earn 200 points to have a perfect score on this examination. Any additional points beyond 200 will be added to your course score. Problem Available Earned 1 20 2 20 3.1 20 3.2 20 3.3 20 4.1 20 4.2 20 4.3 20 4.4 20 4.5 20 4.6 20 5.1 20 5.2 20 6 20 7.1 20 7.2 20 7.3 20 7.4 20 Subtotal 360 Total 1

1. (20 points) Diagram and briefly describe the phases of a compiler. 2. (20 points) Construct a nondeterministic finite automata for the regular expression ( a b) * abb( a b) *. 3. Construct minimum-state DFA s for the regular expression ( a b) * a( a b). 3.1. (20 points) Construct a NFA for the regular expression ( a b) * a( a b). 3.2. (20 points) Convert the NFA found in 3.1. to a DFA. 3.3. (20 points) Minimize the DFA found in 3.2. 4. Create an SLR grammar for logical expressions. 4.1. (20 points) Construct a grammar for logical expressions. Logical expressions have operators and, or, and not as shown in the Table 4. Parenthesized expressions are permitted. Operands consist of 0 or 1, where 0 signifies false and 1 signifies true. Operators are ranked by precedence where the operator having highest precedence is the grouping operator, ( ). Operator Meaning Operands Precedence Associativity ( ) grouping NA 1 left-to-right operator ~ not unary 2 right-to-left * and binary 3 left-to-right + or binary 4 left-to-right Table 4. Logic operators 4.2. (20 points) Construct the first set for all the non-terminals in your grammar. 4.3. (20 points) Construct the follow set for all the non-terminals in your grammar. 4.4. (20 points) Construct the canonical LR(0) collection for your augmented grammar. 4.5. (20 points) Construct the action-goto SLR parsing table for your augmented grammar 4.6. (20 points) Construct a table that records the moves of an LR parser similar to the table shown in Figure 4.38 on page 253 of Compilers: principles, techniques, and tools 2 nd Ed by Aho, Sethi, and Ullman or Figure 4.32 on page 220 of Compilers, principles, techniques, and tools by Aho, Sethi, and Ullman for the expression a + b *c, where a,b, and c are logic variables. 5. Consider the grammar in Table 5. Parse trees are discussed in section 4.2.4 of your text, Compilers: principles, techniques, and tools / Aho, A. V. et al. 2 nd ed. Terminal symbols are printed in bold. Terminal symbols include +, -, *, /, (, ), id, intlit, and realit. An identifier, id, begins with a letter and can have zero or more subsequent letters or digits. An integer literal, intlit, consists of one or more digits. A real literal, realit, is an integer literal and an exponent or a decimal value followed by an optional exponent. A real literal has no embedded blank characters. A decimal value is a decimal point with at least one digit on either side of the decimal point. An exponent is the letter e or E, followed by an optional sign, followed by an integer literal. 1 expression term 2 expression expression+term 3 expression expression-term 4 term factor 5 term term*factor 6 term term/factor 7 factor (expression) 8 factor id 9 factor intlit 10 factor realit Table 5. Expression grammar 2

5.1. (20 points) Construct a parse tree of the expression (f-32)*5/9. 5.2. (20 points) Construct an expression tree for expression (f-32)*5/9. 3

6. (20 points) Draw diagrams that represent symbol table entries for the declaration given in Figure 6. var a:array[-5..4] of char; Figure 6. Declaration for question 6. 7. Translate program p01 in figure 7 to P-Code. Put your answer in Table 7. program p01; var a: integer; function celcius(f:real):real; begin celcius:=(f-32)*5/9 end{celcius}; begin{p01} WriteInteger(celcius(77)) end{p01}. Figure 7. Program for question 7. 7.1. (20 points) Complete the Label Table in Figure 7.1. Label Value Table 7.1 Label Table 7.2. (20 points) Complete the Constant Tables in Figures 7.2. and 7.3. Index Integer constant Table 7.2 Integer constants Index Real constant Table 7.3 Real constants 4

7.3. (20 points) Complete the PCode Instruction Table in Figure 7.4.. Index Label opcode operand 1 operand 2 Table 7.4 P-Code Instructions 5