CS143 Practice Midterm and Solution
Wednesday, July 20
from 11:00 a.m. – 1:00 p.m. in Gates B01
The exam is designed to take roughly 90 minutes, though you will have two hours to
complete the exam. The exam is open-notes, open-book, open-computer, but closed-
network, meaning that you can download any of the handouts and slides that you'd like
in advance, but must not use the Internet, IM, email, etc. during the exam.
The midterm will cover material on the lectures beginning at scanning and ending at
Earley parsing. This means you should fully understand the lexical and syntax analysis
phases of traditional compilation. Material similar to the homework will be
emphasized, although you are responsible for all topics presented in lecture and in the
handouts. Make sure that you have an intuition for the concepts as well as an
understanding, since some of the questions will ask you to think critically about the
different scanning and parsing algorithms.
Possible topics for the midterm include
• Overview of a compiler— terminology, general task breakdown
• Regular expressions— writing and understanding regular expressions, NFAs,
and DFAs; conversion from regular expressions to NFAs; and conversion from
NFAs to DFAs.
• Lexical analysis—scanner generators, flex
• Grammars— Parse trees, derivations, ambiguity, writing simple grammars
• Top-down parsing— LL(1) grammars, grammar conditioning (removing
ambiguity, left-recursion, left-factoring), FIRST and FOLLOW set computation,
table-driven predictive parsing
• Shift-reduce parsing— building LR(0) and LR(1) configurating sets; parse tables,
tracing parser operation; shift/reduce and reduce/reduce conflicts; differences
between LR, SLR, and LALR; and construction of SLR and LALR lookaheads.