Consider the following BNF grammar rules: <pop> ::= [ <bop>, <pop> ] | <bop> <bo
ID: 3784922 • Letter: C
Question
Consider the following BNF grammar rules:
<pop> ::= [ <bop>, <pop> ] | <bop>
<bop> ::= <boop> | ( <pop> )
<boop> ::= x | y | z
For each of the strings listed below, indicate all syntactic categories of which it is a member, if any. (“Syntactic categories” refer to the nonterminal ancestors of a string). In each case, provide a rationale for your response.
a - z
b - ( x )
c - [ y ]
d - ( [ x , y ] )
e - [ ( x ) , y ]
f - [ ( x ), [ y , x ] ]
Explanation / Answer
a. z is boop and any boop is also a bop and a pop.
b.( x ) is a bop -- and therefore also a pop
c. [ y ] is invalid -- cannot have brackets without a comma
d. ( [ x , y ] ) is a bop -- parens around a pop, and therefore also a pop
e. [(x), y] is only a pop -- brackets around a bop and a pop
f. [ (x), [y,x] ] is only a pop -- brackets around a bop and a pop
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.