Quiz #3 Help Center

Learn more

Warning: The hard deadline has passed. You can attempt it, but you will not get credit for it. You are welcome to try it as a learning exercise.

Question 1

Consider the following grammar:

S → A ( S ) B ∣ ϵ
A → S ∣ S B ∣ x ∣ ϵ
B → S B ∣ y

What are the first and follow sets of S?

Question 2

What are the items in the initial state of the SLR(1) parsing automaton for the grammar in last question(Question 1)?
Do not add an extra symbol to the grammar; just use the grammar as is.
[Choose all that apply]

Question 3

Which of the following are true of the initial state of the SLR(1) parsing automaton from the last question (Question 2)?
[Choose all that apply]

Question 4

Consider grammars G1, G2, and G3.

G1: E → idT ∣ (E)T
      T → + id ∣ * id
G2: S → bSb ∣ A ∣ ϵ
      A → aA ∣ ϵ
G3: R → aR' ∣ (R)R'
      R' → ϵ ∣ XR'
      X → . R ∣ + R ∣ *

The number of symbols in the first sets for the *non-terminals* are:

Question 5

Given the following grammar,

stmt→var | if_stmt
if_stmt→if var then stmt | if var then stmt else stmt
var→a | b | win | loss

Which of the following series is a valid bottom-up parsing for the string:
if a then if b then win else loss
[Choose all that apply]

Question 6

For the grammar in last question (Question 5), when applying shift-reduce parsing to the same string:
if a then if b then win else loss
What kind of conflicts will we have?

Question 7

Consider the following grammar:

E → T * E ∣ T
T → int + T ∣ int \mid (E)

Using shift-reduce parsing, how many shift and how many reduce moves does it take to accept the input string:
((int + int)*int)

Question 8

Consider the following grammar:

S \rightarrow Sb \mid a

This grammar is:

Question 9

Consider the following grammar:

S \rightarrow SbS \mid a

This grammar is:

Question 10

Consider the following grammar:

S \rightarrow bS \mid a

This grammar is:

Question 11

Which of the following statements are true about this grammar:

S \rightarrow aTUb \mid \epsilon
T \rightarrow cUc \mid bUb \mid aUa
U \rightarrow Sb \mid cc
    
You cannot submit your work until you agree to the Honor Code. Thanks!