Professional Documents
Culture Documents
Introduction
- {anbn : n = 0, 1, 2, …}
- {w : w a is palindrome}
G = (V, , P, S)
V = variables a finite set
= alphabet or terminals a finite set
P = productions a finite set
S = start variable SV
• u = xz
• v = xz
• in R
u u1 u2 … v
Context-Free Languages
L(G) = {w : S * w }
In proofs…
Restrict attention to left- or rightmost derivations.
In parsing algorithms…
Restrict attention to left- or rightmost derivations.
E.g., recursive descent uses leftmost; yacc uses rightmost.
Derivation Trees
S A|AB
Other derivation
A |a|Ab|AA w = aabb
trees for this string?
B b|bc|Bc|bB
S S
S ? ?
A
A B A B
A A Infinitely
A A b B A A b many others
A A A b possible.
a a b a A b
a A b
a
a
Ambiguous Grammar