PLC Nick Flashcards

(5 cards)

1
Q

Describe what it means for a grammar to be ambiguous

A

A grammar is ambiguous if two or more parse trees can be derived for a given string

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

In the exam, how should you show ambiguity?

A

Do parse trees, or much easier is to select a part of the grammar and double it, such that it’s not clear what’s first or not. Like selecting the rule E;E, put down (E;E);E, E;(E;E). Make sure to replace E with actual values

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

In a layered grammar, how do you show binding?

A

Loosest at the top, Tightest at the bottom

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

In a grammar, how do you show left/right association?

A

F::= F;G|G, F is forced to left of ; so ; is left associated. F::= G;F|G, F is forced to right of ; so ; is right associated.

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

E ::= xD | D | if (E < D)then E | E:=E +E |E;E |(E)
D::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

A

E ::= if (E<D) then E | F
F ::= F;G | G
G ::= H := E + G | H
H ::= xD | D | (E)

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