[Overview] [Previous]
[Next]
Example
Consider the grammar G = ({S, A, B}, {a, b}, S, P), where
P = {S
a, S
aAB,
A
aA, A
a,
B
bB, B
b}.
These productions can be turned into transition functions
by rearranging the components:
This yields the following table:
|
(start)
|
(q0,
,
z) {(q1,
Sz)}
|
S a, |
(q1,
a, S) {(q1,
)}
|
S aAB, |
(q1,
a, S) {(q1,
AB)}
|
A aA, |
(q1,
a, A) {(q1,
A)}
|
A a, |
(q1,
a, A) {(q1,
)}
|
B bB, |
(q1,
b, B) {(q1,
B)}
|
B b |
(q1,
b, B) {(q1,
)}
|
|
(finish)
|
(q1,
,
z) {(qf,
z)}
|
For example, the derivation
S
aAB
aaB
aabB
aabb
maps into the sequence of moves
(q0, aabb, z)
(q1, aabb, Sz)
(q1, abb, ABz)
(q1, bb, Bz)
(q1,
b, Bz)
(q1,
, z)
(q2,
,
)
Copyright © 1996 by David Matuszek
Last modified Mar 17, 1996