Professional Documents
Culture Documents
Nguyễn Đức Phi Hồng ITITIU 17022- Principles of Programming Languages- Excercise 3
Nguyễn Đức Phi Hồng ITITIU 17022- Principles of Programming Languages- Excercise 3
ID : ITITIU17022
Principles of Programming Languages Exercises 3
t→Ct|
a. BACC
b. AC
c. AACC
d. BCCC
Answer: d
2. Which string can be generated by the following grammar?
s→ A s B | n
n →C |
a. AACBBB
b. AAnBB
c. AAA BBB
d. AAABBB
Answer: d
Invalid Grammar
1. A grammar is invalid when it cannot generate a string of terminal symbols. Which grammar is
invalid?
a. s→ A s | B s
b. s→ A | B s
c. s→ A s | B
d. a→ A | B
Answer: d
2. A grammar is invalid when it cannot generate a string of terminal symbols. Which grammar is
invalid?
a. s→ A s | t
r→ B r | C
b. s → B r
r→Br|
c. s → A s | B r | D
r→Br|C
d. s → A s B r | D
r→Br|
Answer: b
Select Grammar
1. Which is the grammar of a nullable SM-separated list of statements where stmt is a nonterminal
symbol representing a statement?
2. Which is the grammar of a nullable SM-separated list of statements where stmt is a nonterminal
symbol representing a statement?
a. stmtlist →stmt stmtlp
Syntax Tree
1.
S→AB
A→aAa|
B→bB|b
Draw syntax tree for aabb ?
Answer: c
2. Grammar
S→AB
A→aA|a
B→bBb|
Input: aabb ?
Answer: b