What do you mean by context-free grammar? What are the components of the grammar?
[2021, 17, 10]
Or,
Define CFG. What are the components of CFG?
[2013]
Define CFG, parse tree, and syntax tree.
[2015, 10]
CFG
Consider the following Context-Free Grammar (CFG):
stmt → expr;
expr → expr + term | term
term → term * factor | factor
factor → number | (expr)
number → 0 | 1 | 2 | ... | 9
(i) Show how the string 1 + 2*(3 + 4) + 5
can be generated by this grammar.
(ii) Construct a parse tree for the string.[2018]
Parsing Table
What do you mean by CFG? Consider the following grammar: Now, draw the parsing table.[2020, 15, 12]
S → C + S | ε
C → b
Parse Tree for 9-5+2
Derive a parse tree for 9-5+2
according to the following rules or productions:[2019, 18]
list → list + digit
list → list - digit
list -> digit
digit → 0 | 1 | 2 | ... | 9
Predictive Parsing
What is predictive parsing? Construct the parsing table for the following grammar:[2014, 13]
E → T E'
E → + T E' | ε
T → F T'
T' → * F T' | ε
F → (E) | id
CFG Example
Consider the context-free grammar:
S → S + S | S * S | a
**(i) Show how the string aa + a *
can be generated by this grammar.
(ii) Construct a parse tree for this string.[2021, 17, 10]
Or,
Consider the context-free grammar:Show how the string xx + x *
can be generated by this grammar.[2013]
S → SS+ | SS* | x