Docsity

Midterm Examination for ECS 142 - Spring 1997, Exams of Computer Science

Toggle sidebar
bg1
Name (Last, First):,
Midterm Examination
May 8th 1997
Score: /100
Directions
๎˜€
This exam consists of 3 questions on 6 pages; be sure that you have the entire exam before starting.
๎˜€
Make sure that you write your name on every page of the exam.
๎˜€
Answer each question in the space following the question. If you find it necessary to continue an answer
elsewhere, indicate clearly the location of its continuation and label its continuation with the question number.
๎˜€
The point value of each question is indicated at its beginning. The entire exam has 100 points.
๎˜€
Be concise and indicate clearly what your answer is. Presentation and simplicity of your answers may affect
your grade.
๎˜€
You have 80 minutes.
ECS 142 โ€“1โ€“ Spring 1997
pf3
pf4
pf5

Partial preview of the text

Download Midterm Examination for ECS 142 - Spring 1997 and more Exams Computer Science in PDF only on Docsity!

Name (Last, First) : ,

Midterm Examination May 8th 1997

Score: /

Directions

This exam consists of 3 questions on 6 pages; be sure that you have the entire exam before starting.

Make sure that you write your name on every page of the exam.

Answer each question in the space following the question. If you find it necessary to continue an answer elsewhere, indicate clearly the location of its continuation and label its continuation with the question number. The point value of each question is indicated at its beginning. The entire exam has 100 points.

Be concise and indicate clearly what your answer is. Presentation and simplicity of your answers may affect your grade. You have 80 minutes.

Problem 1 (35 Points)

Problems 1.a and 1.b require you to construct a predictive parser for the following grammer:

      ! " # $ % & id

 " '(" #   )%

1.a) (8 Points) Find *

 +,.- and * /

 / 0 sets for the nonterminals of the grammar:

First(Expr) = Follow(Expr) =

First(Var) = Follow(Var) =

First(ExprTail) = Follow(ExprTail) =

First(VarTail) = Follow(VarTail) =

1.b (11 Points) Show the predictive parser table for the grammar

id

  $ Expr

ExprTail

Var

VarTail

Problem 2 (35 Points)

This problem deals with LR(1), LALR(1), and LR(1) parsers. The context free grammar of interest in problems 2.a and 2.b is:

 (^)  

 (^)  %

 stmt

2.a (13 Points) Construct LR(0) items for the grammar.

2.b (12 Points) Construct the SLR(1) parser table for the grammar.

2.c (3+7 Points) Is the following grammar an LR(1) grammar? Describe the reasons for your answer.

 id 

 id 

  

 id