In: Computer Science
#1
We are given the grammar rules
A ➝ F B E
B ➝ A C
These rules are only some of the rules of a larger grammar G, but we are not given the remaining rules of G. We are told that A is the start symbol of G and that the following holds:
{ε, c, d} ⊆ FIRST(C)
{ε, e} ⊆ FIRST(E)
{ε, f, g} ⊆ FIRST(F)
Recall that end of file is denoted EOF. The symbol ⊆ is used to denote set inclusion. For example, {ε, c, d} ⊆ FIRST(C) means that ε, c, and d are all elements of FIRST(C). Which of the following must hold?
c ∈ FIRST(B)
EOF ∈ FIRST(B)
a ∈ FIRST(B)
ε ∈ FIRST(B)
f ∈ FIRST(B) -- Correct Answer
d ∈ FIRST(B)
Need explanation on how to get First(A) and First(B).
#2
We are given the grammar rules
A ➝ F E
B ➝ A C
These rules are only some of the rules of a larger grammar G, but we are not given the remaining rules of G. We are told that A is the start symbol of G and that the following holds:
{ε, c, d} ⊆ FIRST(C)
{ε, e} ⊆ FIRST(E)
{ε, f, g} ⊆ FIRST(F)
Recall that end of file is denoted EOF. The symbol ⊆ is used to denote set inclusion. For example, {ε, c, d} ⊆ FIRST(C) means that ε, c, and d are all elements of FIRST(C). Which of the following must hold (more than one choice or no choice can be correct)?
ε ∈ FIRST(B) -- Correct Answer
EOF ∈ FIRST(B)
f ∈ FIRST(B) -- Correct Answer
d ∈ FIRST(B) -- Correct Answer
c ∈ FIRST(B) -- Correct Answer
I can get {f,g,e} for First(B). Need explanation why empty, d, and c are a part of First(B).