Professional Documents
Culture Documents
Context-Free Grammars
Language generated by a CFG
Derivation sequence
Leftmost derivation sequence
Rightmost derivation sequence
Parse tree (Derivation tree)
Yield of a parse tree
Recursive inference
Examples:
1) A
A0
A1
A 0 A0
A 1 A1
2) L = {0n1n | n 0}
lm
lm
rm
rm
Example:
EE+T|T
TT*F|F
F (E) | a
Example:
S SS | (S) |
Recursive inference:
S w0X1w1X2w2 Xkwk
wi in T* and Xj in V
Then w generated by S is the concatenation
wi and strings generated by Xj in the order
Leftmost
derivation
Rightmost
derivation
Derivation
Parse tree
Recursive
inference
Example:
(1) E E + E | E * E | (E) | a
is ambiguous
(2) L = {aibjck | i = j or j = k}
is inherently ambiguous