CFG To PDA Conversion
CFG To PDA Conversion
GNF FORM:
Step 3: The initial symbol of CFG will be the initial symbol in the
PDA.
1. δ(q, ε, A) = (q, α)
Convert the following grammar to a PDA that accepts the same language.
1. S → 0S1 | A
2. A → 1A0 | S | ε
Solution:
The CFG can be first simplified by eliminating unit productions:
1. S → 0S1 | 1S0 | ε
1. S → 0SX | 1SY | ε
2. X → 1
3. Y → 0
Example 2:
Construct PDA for the given CFG, and test whether 0104 is acceptable
by this PDA.
1. S → 0BB
2. B → 0S | 1S | 0
Solution:
1. S → aSb
2. S → a | b | ε
Solution: