Question Marks 1 /12 2 /6 3 /14 4 /8 5 /5 6 /16 7 /34 8 /25 Total /120

Similar documents
Question Marks 1 /11 2 /4 3 /13 4 /5 5 /11 6 /14 7 /32 8 /6 9 /11 10 /10 Total /117

Question Marks 1 /20 2 /16 3 /7 4 /10 5 /16 6 /7 7 /24 Total /100

Question Marks 1 /16 2 /13 3 /12 4 /15 5 /8 6 /15 7 /8 8 /5 9 /8 Total /100

CPSC 121 Midterm 1 Friday October 14th, Signature: Section (circle one): 11:00 15:30 17:00

CS 411 Midterm Feb 2008

CPSC 320 Midterm 2. July 13, 2007

CPSC 121 Sample Final Examination December 2013

CPSC 121 Midterm 1 Friday February 5th, Signature: Section (circle one): Morning Afternoon

CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #1 Examination 12:30 noon, Tuesday, February 14, 2012

Full Name: CS Account:

CPSC 411, 2015W Term 2 Midterm Exam Date: February 25, 2016; Instructor: Ron Garcia

UNIVERSITY REGULATIONS

MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012

BSCS Fall Mid Term Examination December 2012

Computer Science 304

EXAMINATION INSTRUCTIONS

This examination has 11 pages. Check that you have a complete paper.

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 110: MIDTERM 1 Part B May 26, Important notes about this examination

EXAMINATION INSTRUCTIONS

2068 (I) Attempt all questions.

UNIVERSITY REGULATIONS

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

CPSC 311, 2010W1 Midterm Exam #2

The University of British Columbia Final Examination - December 02, 2014 Mathematics 308. Closed book examination. No calculators.

COP4020 Spring 2011 Midterm Exam

CPSC 410? Advanced Software Engineering Mid-term Examination (Term I ) SOLUTION Instructor: Gail Murphy

CS143 Midterm Sample Solution Fall 2010

A language is a subset of the set of all strings over some alphabet. string: a sequence of symbols alphabet: a set of symbols

Midterm I (Solutions) CS164, Spring 2002

CS 415 Midterm Exam Spring 2002

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 261: MIDTERM 1 February 14, 2017

MIDTERM EXAM (Solutions)

EXAMINATION INSTRUCTIONS

CPSC 410 Advanced Software Engineering Mid-term Examination (Term I ): Solution Instructor: Gail Murphy

CS 415 Midterm Exam Spring SOLUTION

MidTerm Papers Solved MCQS with Reference (1 to 22 lectures)

UNIVERSITY OF CALIFORNIA

ECE251 Midterm practice questions, Fall 2010

CPS 506 Comparative Programming Languages. Syntax Specification

THE UNIVERSITY OF BRITISH COLUMBIA CPSC 121: MIDTERM 2 Group March 12, 2014

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

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

The University of British Columbia Computer Science 304 Practice Final Examination

1. Explain the input buffer scheme for scanning the source program. How the use of sentinels can improve its performance? Describe in detail.

CS143 Midterm Fall 2008

CS164: Midterm I. Fall 2003

R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.

CSE 130 Programming Language Principles & Paradigms Lecture # 5. Chapter 4 Lexical and Syntax Analysis

CS3360 Design and Implementation of Programming Languages Final Exam May 16, pm to 12:45pm (2 hour and 40 minutes) NAME:

CSE3322 Programming Languages and Implementation

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

CPSC 126 SAMPLE FINAL EXAMINATION ANSWERS April, 2003

COMPILER DESIGN. For COMPUTER SCIENCE

Dr. D.M. Akbar Hussain

Philadelphia University Faculty of Information Technology Department of Computer Science --- Semester, 2007/2008. Course Syllabus

Monday, September 13, Parsers

CSCI Compiler Design

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

The University of Oregon May 16, 2015 Oregon Invitational Mathematics Tournament:

MATH 253/101,102,103,105 Page 1 of 12 Student-No.:

CMSC330 Spring 2014 Midterm #2. Score 1 OCaml types & type

RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 96 INSTRUCTIONS

Recursive Descent Parsers

EXAMINATION INSTRUCTIONS

Homework. Context Free Languages. Before We Start. Announcements. Plan for today. Languages. Any questions? Recall. 1st half. 2nd half.

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

1. The output of lexical analyser is a) A set of RE b) Syntax Tree c) Set of Tokens d) String Character

Talen en Compilers. Johan Jeuring , period 2. January 17, Department of Information and Computing Sciences Utrecht University

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

Chapter 4. Lexical and Syntax Analysis

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING Subject Name: CS2352 Principles of Compiler Design Year/Sem : III/VI

BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, Pilani Pilani Campus Instruction Division

Chapter 3 (part 3) Describing Syntax and Semantics

EXAM. CS331 Compiler Design Spring Please read all instructions, including these, carefully

ECE 468/573 Midterm 1 October 1, 2014

CS143 Midterm Spring 2014

Final Term Papers 2013

The Parsing Problem (cont d) Recursive-Descent Parsing. Recursive-Descent Parsing (cont d) ICOM 4036 Programming Languages. The Complexity of Parsing

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

ECE 468/573 Midterm 1 September 30, 2015

Abstract Syntax Trees & Top-Down Parsing

Programming Language Syntax and Analysis

Abstract Syntax Trees & Top-Down Parsing

Abstract Syntax Trees & Top-Down Parsing

Syntax. In Text: Chapter 3

Class Information ANNOUCEMENTS

QUESTIONS RELATED TO UNIT I, II And III

CMSC 330, Fall 2018 Midterm 2

First Midterm Exam CS164, Fall 2007 Oct 2, 2007

The University of Oregon May 16, 2015 Oregon Invitational Mathematics Tournament:

CSE 413 Final Exam. June 7, 2011

COP5621 Exam 3 - Spring 2005

4. Lexical and Syntax Analysis

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

1. Consider the following program in a PCAT-like language.

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Compiler Design

Chapter 3. Syntax - the form or structure of the expressions, statements, and program units

Parsers. Xiaokang Qiu Purdue University. August 31, 2018 ECE 468

Programming Languages, Summary CSC419; Odelia Schwartz

Transcription:

CSC 326, Midterm October 25, 2004 Name: Student ID: Signature: You have 75 minutes to write the 8 questions on this examination. A total of 120 marks is available. Justify all of your answers You may use one sheet of handwritten notes. Keep your answers short. If you run out of space for a question, you have written too much. The number in square brackets to the right of the question number indicates the number of marks allocated for that question. Use these to help you determine how much time you should spend on each question. Question Marks 1 /12 2 /6 3 /14 4 /8 5 /5 6 /16 7 /34 8 /25 Total /120 Use the back of the page for rough work. Good luck UNIVERSITY REGULATIONS: No candidate shall be permitted to enter the examination room after the expiration of one half hour, or to leave during the first half hour of the examination. CAUTION: Candidates guilty of any of the following, or similar, dishonest practices shall be immediately dismissed form the examination and shall be liable to disciplinary action. 1. Making use of any books, papers or memoranda, electronic equipment, or other memory aid devices, other than those authorized by the examiners. 2. Speaking or communicating with other candidates. 3. Purposely exposing written papers to the view of other candidates. The plea of accident or forgetfulness shall not be received. 1

Language Design Issues Question 1 [12 points] [4/12] Give at least one pro and one con for implementing a language using an interpreter, and give at least one pro and one con for implementing a language using a compiler. [2/12] What does orthogonal mean with respect to a programming language? [2/12] What does data abstraction entail? (Question 1 continued on next page) 2

Language Design Issues [4/12] List, and briefly explain, the process/steps taken by a compiler to turn source code into object code and/or an executable. (End of question 1) 3

Java Question 2 [6 points] [3/6] Is Java compiled, interpreted, or a hybrid? Briefly explain. [3/6] Give an example of something in Java or C/C++ that must be checked for a program to be valid, but cannot be described by EBNF (i.e., give an example of static semantics for Java or C/C++.) (End of question 2) 4

Context-free Languages and EBNF Question 3 [14 points] Consider the following context-free grammar: E E + E id ɛ [5/14] Show a rightmost derivation of id + id + id and draw the parse tree. [5/14] Show a leftmost derivation of id + id + id and draw the parse tree. [4/14] Can you write a recursive descent parser for the grammar? if yes, do so, if no, explain why not. (End of question 3) 5

Weakest Precondition Question 4 [8 points] [4/8] Compute the weakest precondition for a = b 2 {a < 12} 3 [4/8] What does a weakest precondition tell us? (End of question 4) 6

Denotational Semantics Question 5 [5 points] Consider the following semantic function: M bin [ 0 ] = 0 M bin [ 1 ] = 1 M bin [ xxx0 ] = 2 M bin [ xxx ] M bin [ xxx1 ] = 2 M bin [ xxx ] + 1 Use M bin [ ] to calculate the decimal value of 10110. Show each step. (End of question 5) 7

Formal Languages and Lexical Analyzers Question 6 [16 points] [3/16] What formalism is used to describe the the possible textual values of the tokens returned by a lexical analyzer? [4/16] Describe (in words) the language (A) of the following regular expression: aa b(a b) [4/16] Determine if the following string are in L(A): aaa? abba? 8

Formal Languages and Lexical Analyzers [5/16] Is a n b n, n 0, a regular language? Explain why/why not. (End of question 6) 9

Question 7 [34 points] Parsing [4/34] What is the major difference between a top-down and a bottom-up parser? [4/34] Using EBNF, construct a context-free grammar that cannot be parsed using an LL parser. Consider the following grammar: [3/34] Is this grammar LL(1)? A ab aa bb B a b (Question 7 continued on next page) 10

Now consider this: S aa B ca ɛ A a B B b [6/34] Compute FIRST(S), FIRST(A), and FIRST(B). [4/34] State, using FIRST sets a necessary general condition that must be satisfied for all production X i α i,1 α i,2... α i,ni [4/34] Briefly explain the 2 major actions of a shift/reduce parser. (Question 7 continued on next page) 11

Parsing [3/34] Is the set of languages parsable by LL parsers smaller, larger, or the same as the set of languages parsable by LR parsers? [6/34] Explain the difference between synthesized, inherited, and intrinsic attributes. (End of question 7) 12

Types, Binding and Type Checking Question 8 [25 points] [4/25] Briefly explain why we do not want all variables and parameters to be static by default, i.e., why do we not want all variables and parameters to have fixed addresses assigned by the compiler? [4/25] List at least 4 different binding times and give an example (one line of code) for each. [3/25] How can dynamic type bindings help reduce the amount of lines of code in a program? (Question 8 continued on next page) 13

Types, Binding and Type Checking [3/25] Java does not have dynamic type bindings, but does have a mechanism that works almost like it. What is it? (Hint: This Object Oriented). [3/25] What is a heap dynamic variable? Give an example. [5/25] What does it mean if a language is strongly typed? (Question 8 continued on next page) 14

Types, Binding and Type Checking [3/25] Why is structured type compatibility harder to implement than name compatibility. (End of question 8) (End of the exam) 15