Computer Science Spring 98 Midterm Examination Professor L. Rowe

Similar documents
CS 61B, Spring 1996 Midterm #1 Professor M. Clancy

CS61A, Fall/1999 Midterm #1 Professor Brian Harvey

CS164 Spring 1997 Midterm 1

CS 61B, Summer 2001 Midterm Exam II Professor Michael Olan

CS162, Spring/1992 Midterm #2 Professor Thomas Anderson

Midterm I (Solutions) CS164, Spring 2002

CS 170, Spring 2000 Midterm #1 Professor M. Clancy

CS 61B, Spring 1996 Midterm #1 Professor M. Clancy

CS143 Midterm Spring 2014

CS 61A Midterm #2 - October 5, 1998

CSE P 501 Compilers. LR Parsing Hal Perkins Spring UW CSE P 501 Spring 2018 D-1

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

Bottom-Up Parsing. Lecture 11-12

UNIVERSITY OF CALIFORNIA

WARNING for Autumn 2004:

COP 3402 Systems Software Syntax Analysis (Parser)

Lecture 8: Deterministic Bottom-Up Parsing

CS61B, Fall 1995 Midterm #2 K. Yelick

CS184, Fall 1997 Midterm #1 Professor Brian A. Barksy

Lecture Notes on Bottom-Up LR Parsing

11/22/1999 7pm - 9pm. Name: Login Name: Preceptor Name: Precept Number:

Lecture 7: Deterministic Bottom-Up Parsing

Downloaded from Page 1. LR Parsing

Compiler Construction 2016/2017 Syntax Analysis

BSCS Fall Mid Term Examination December 2012

Problem Score Max Score 1 Syntax directed translation & type

Lecture Notes on Bottom-Up LR Parsing

Lexical and Syntax Analysis. Bottom-Up Parsing

CS61B (Clancy) Spring 1996 Exam 3, solutions, and grading standards. April 12, 1996 Exam 3

Let us construct the LR(1) items for the grammar given below to construct the LALR parsing table.

Bottom-Up Parsing. Lecture 11-12

Parsing. source code. while (k<=n) {sum = sum+k; k=k+1;}

CS 184, Fall 1996 Midterm #1 Professor: unknown

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

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

Syntax Analysis Part I

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

Midterm I - Solution CS164, Spring 2014

CSE 401 Compilers. LR Parsing Hal Perkins Autumn /10/ Hal Perkins & UW CSE D-1

Computer Science /21/2000

CSE 582 Autumn 2002 Exam 11/26/02

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

Table-Driven Parsing

CSCI Compiler Design

McGill University School of Computer Science COMP-202A Introduction to Computing 1

Chapter 3: Lexing and Parsing

Derivations of a CFG. MACM 300 Formal Languages and Automata. Context-free Grammars. Derivations and parse trees

CS 61C, Midterm #2, Spring 1997 CS 61C. Spring 1997 Midterm #2. Professor Brian Harvey

Action Table for CSX-Lite. LALR Parser Driver. Example of LALR(1) Parsing. GoTo Table for CSX-Lite

CSE P 501 Compilers. Parsing & Context-Free Grammars Hal Perkins Winter /15/ Hal Perkins & UW CSE C-1

Configuration Sets for CSX- Lite. Parser Action Table

Plan for Today. Regular Expressions: repetition and choice. Syntax and Semantics. Context Free Grammars

Syntax Analysis, V Bottom-up Parsing & The Magic of Handles Comp 412

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

How do LL(1) Parsers Build Syntax Trees?

CS 314 Principles of Programming Languages

Conflicts in LR Parsing and More LR Parsing Types

UNIT III & IV. Bottom up parsing

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

CMSC330 Spring 2018 Midterm 2 9:30am/ 11:00am/ 3:30pm

ECE251 Midterm practice questions, Fall 2010

CS 61B, Spring 1999 MT3 Professor M. Clancy

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

COMP 401 Midterm. Tuesday, Oct 18, pm-3:15pm. Instructions

W09 CPSC 219 Midterm Exam Page 1 of 7

Question Points Score

MIDTERM EXAM (Solutions)

EECS 211 Spring Quarter, 2010 Program 5 Due Tuesday, May 18th, 2010 at 11:59PM

CS 314 Principles of Programming Languages. Lecture 3

CS 101 Fall 2006 Midterm 1 Name: ID:

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

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

CSE 431S Final Review. Washington University Spring 2013

EE 122, Spring 1997 Midterm #2 Professor Edell

8 Parsing. Parsing. Top Down Parsing Methods. Parsing complexity. Top down vs. bottom up parsing. Top down vs. bottom up parsing

CS 536 Midterm Exam Spring 2013

Parsing III. CS434 Lecture 8 Spring 2005 Department of Computer Science University of Alabama Joel Jones

Classes and Objects 3/28/2017. How can multiple methods within a Java class read and write the same variable?

MIDTERM EXAMINATION - CS130 - Spring 2005

CSCI312 Principles of Programming Languages!

Top down vs. bottom up parsing

Midterm Exam #2 April 20, 2016 CS162 Operating Systems

Syntax Analysis. Amitabha Sanyal. ( as) Department of Computer Science and Engineering, Indian Institute of Technology, Bombay

CMSC330 Spring 2017 Midterm 2

Error Detection in LALR Parsers. LALR is More Powerful. { b + c = a; } Eof. Expr Expr + id Expr id we can first match an id:

University of Technology Department of Computer Sciences. Final Examination st Term. Subject:Compilers Design

Compilation 2013 Parser Generators, Conflict Management, and ML-Yacc

4. Lexical and Syntax Analysis

In One Slide. Outline. LR Parsing. Table Construction

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

Computing Inside The Parser Syntax-Directed Translation. Comp 412

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

MIDTERM EXAMINATION - CS130 - Spring 2003

Chapter 4. Lexical and Syntax Analysis

LL(k) Parsing. Predictive Parsers. LL(k) Parser Structure. Sample Parse Table. LL(1) Parsing Algorithm. Push RHS in Reverse Order 10/17/2012

PART 3 - SYNTAX ANALYSIS. F. Wotawa TU Graz) Compiler Construction Summer term / 309

4. Lexical and Syntax Analysis

CSCI Compiler Design

Recursive Descent Parsers

LR Parsing LALR Parser Generators

Transcription:

Computer Science 164 - Spring 98 Midterm Examination Professor L. Rowe Problem #1 (30 points) Define the following terms: parser terminal symbol abstract class method abstract syntax tree pushdown automaton grammar rule automatic parser generator handle instance arbitrary rewrite system syntax directed translation rvalue leftmost derivation reduce/reduce error Problem #2 (10 points) Answer the following: T F A pushdown automaton can recognize a language defined by a regular grammar. T F A bottom-up parser performs reductions in the same order as a rightmost derivation. T F A variable declared in Java to be a type Class can reference the object Object. T F Class variables cannot be defined in a Java abstract class. T F A nondeterministic fsa can recognize languages that a deterministic fsa cannot recognize. Problem #3 file:///c /Documents%20and%20Settings/Jason%20Raft...-%20Spring%201998%20-%20Rowe%20-%20Midterm%201.htm (1 of 6)1/27/2007 5:32:58 PM

(20 points) Answer the following questions given the fsa: a) Identify which sentences are recognized by this automaton. Yes No aab Yes No bbabca Yes No bcaabaaabaa Yes No bbcb Yes No abbbbabbabca b) Show a left regular grammar that specifies the language recognized by the fsa. (Hint: write a grammar rule which would produce the fsa using the algorithm given in class.) c) Describe in English the language recognized by the fsa. Problem #4 file:///c /Documents%20and%20Settings/Jason%20Raft...-%20Spring%201998%20-%20Rowe%20-%20Midterm%201.htm (2 of 6)1/27/2007 5:32:58 PM

(20 points) Given the following LR parser tables and grammar rules, answer the following questions. a ( ) $ S L 0 s2 s3.. 1. 1... acc.. 2 r1 r1 r1 r1.. 3 s2 s3.. 5 4 4 s2 s3 s6. 7. 5 r3 r3 r3 r3.. 6 r2 r2 r2 r2.. 7 r4 r4 r4 r4.. The grammar is 1: S -> a 2: S -> '('L')' 3: L -> S 4: L -> LS a) Show the parse tree for the sentence "( ( a ( a ) ) )". b) Show the parser configurations as it parses that input in the following table. You must use state numbers on the syntax stack. (Hint: 22 configurations are shown in the table -- the parse may take less than, more than, or equal to that number of steps.) step stack input action 1 0 ( ( a ( a ) ) ) $ shift 3 2 0 3 ( a ( a ) ) ) $ shift 3 3 4 5 6 file:///c /Documents%20and%20Settings/Jason%20Raft...-%20Spring%201998%20-%20Rowe%20-%20Midterm%201.htm (3 of 6)1/27/2007 5:32:58 PM

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 Problem #5 file:///c /Documents%20and%20Settings/Jason%20Raft...-%20Spring%201998%20-%20Rowe%20-%20Midterm%201.htm (4 of 6)1/27/2007 5:32:58 PM

(20 points) Given the Java program fragments: C.java: D.java: Hello.java: package p; public class C { public int x; protected double y; private char z; public char getz( ) { return z; package p; public class D extends C { String S; public void f( ) { S = ((Integer)x).toString( ); package p; public class Hello { public static void main(string[] args) { C ac = new C(); D ad = new D(); a) Which instance variables can be accessed using the object ac in the method main? b) Which instance variables can be accessed using the object ad in the method main? c) Which instance variables can be accessed in the method called by D.f() in the method main? Total: 100 points file:///c /Documents%20and%20Settings/Jason%20Raft...-%20Spring%201998%20-%20Rowe%20-%20Midterm%201.htm (5 of 6)1/27/2007 5:32:58 PM

Posted by HKN (Electrical Engineering and Computer Science Honor Society) University of California at Berkeley If you have any questions about these online exams please contact mailto:examfile@hkn.eecs.berkeley.edu Created undefined file:///c /Documents%20and%20Settings/Jason%20Raft...-%20Spring%201998%20-%20Rowe%20-%20Midterm%201.htm (6 of 6)1/27/2007 5:32:58 PM