






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The university of michigan eecs 483 fall 2003 exam 1 for computer science. The exam consists of 12 questions divided into two parts: short problems and design problems. The short problems section includes questions on regular expressions, parsing, and context-free grammars. The design problems section includes questions on constructing abstract syntax trees, identifying errors in code segments, and converting grammars to ll(1) form. Students are required to show their work and the exam is open book and open notes.
Typology: Exams
1 / 10
This page cannot be seen from the preview
Don't miss anything!







Please sign indicating that you have upheld the Engineering Honor Code at the University of Michigan.
"I have neither given nor received aid on this examination."
There are 12 questions divided into 2 sections. The point value for each question is specified with that question. Please show your work unless the answer is obvious. If you need more space, use the back side of the exam sheets.
Part I: Short Problems 8 questions, 55 pts total Score:_____
Part II: Design Problems 4 questions, 95 pts total Score:_____
Total (150 possible): _______
Part I. Short Answer Problems (Questions 1-8)
3 A context free grammar is capable of representing more languages than a regular expression. What is the major reason for this? (5 pts)
stmt: IF OP_PAR arith_expr CL_PAR OP_BCS decls statements CL_BCS { ... } | IF_OP_PAR arith_expr CL_PAR OP_BCS decls statements CL_BCS ELSE OP_BCS decls statements CL_BCS { ... } ... ;
There is a shift/reduce error in the above grammar when parsing “if (arith_expr)” as the grammar does not know whether to shift and look for the corresponding “else” or to reduce and just parse the “if”. However, bison does not generate an error, why is this? (5 pts)
Part II. Design Problems (Questions 9-13)
Consider the following regular expression: a((b|a)(c|d)+)*
(a). Construct the NFA for this regular expression. (10 pts)
(b). Convert the constructed NFA to a DFA. (10 pts)
(c). Construct the FIRST and FOLLOW sets for each non-terminal (S, A, B, C) on the following LL(1) grammar. (15 pts) S Æ AB A Æ bC B Æ aAB | ε C Æ (S) | c
Consider the following grammar: E Æ E + T | T T Æ TF | F F Æ F* | a | b (Note * is not the closure operator!)
(a). Construct the LR(0) DFA for this grammar. (15 pts)
(b). Are there any shift/reduce conflicts in the parsing table that would result from the DFA constructed above. Explain your answer. Note that you do not need to construct the parse table. (5 pts)
(b). Is the following expression well-typed in a particular context? If so, indicate the result type. Explain your answer. (5 pts) pop(push(x,y+5))
(c). Is the following expression well-typed in a particular context? If so, indicate the result type. Explain your answer. (5 pts) push(newstack(int), top(x)) + push(y,empty(z))