CFG → PDA
Enter a Context-Free Grammar to generate its equivalent Pushdown Automaton
Insert:
CFG → PDA Conversion Results

Conversion Steps

PDA Transition Table

StateInputStack Top Next StatePushRule

PDA Graph

PDA → CFG
Enter a Pushdown Automaton to generate its equivalent Context-Free Grammar
Insert:
PDA → CFG Conversion Results

Generated CFG

PDA Graph

CFG → PDA

aⁿbⁿ Language

Strings with equal number of a's followed by b's — the canonical CFL example.

S → aSb | ε
CFG → PDA

Palindromes over {a,b}

Strings that read the same forwards and backwards, requiring non-determinism.

S → aSa | bSb | a | b | ε
PDA → CFG

PDA for aⁿbᵐ (m > n)

2-state PDA: push A for each 'a', pop for each 'b', accept when more b's than a's.

q,a,Z → q,AZ
q,b,A → q,ε
q,b,Z → p,Z
p,b,Z → p,Z
p,ε,Z → p,ε
PDA → CFG

PDA for Balanced Parens

Push on '(', pop on ')', accept when stack marker Z is on top.

q0,ε,ε → q1,Z
q1,(,ε → q1,P
q1,),P → q1,ε
q1,ε,Z → q2,ε