CHAPTER 4 Flashcards

1
Q

What does it mean for a grammar to be ambiguous?

A

A grammar is ambiguous if there exists at least one string in its language that has two or more different parse trees.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does it mean for two grammars to be equivalent?

A

Two grammars
𝐺
1
G
1

and
𝐺
2


are equivalent if they generate the same language
𝐿
(
𝐺
1
)
=
𝐿
(
𝐺
2
)
L(G
1

)=L(G
2

).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. What is “left factoring”?
A

A transformation used to eliminate common prefixes to make a grammar suitable for LL parsing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is “left recursion”?

A

A grammar has left recursion if a nonterminal calls itself as the first symbol in its production.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can LL(k) parsing algorithms handle common prefixes and left recursion?

A

LL(k) cannot handle left recursion (must eliminate it).
LL(k) struggles with common prefixes, but left factoring fixes this.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can LR(k) parsing algorithms handle common prefixes and left recursion?

A

LR(k) parsers can handle left recursion naturally (no need for transformation).
LR(k) can also handle common prefixes without modification.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly