def display_grammar(grammar):
print("LHS\t→ RHS")
print("-----------------")
for lhs, productions in grammar.items():
for rhs in productions:
print(f"{lhs}\t→ {rhs}")
# Example Grammar
# S → aA | bB
# A → a | ε
# B → b
grammar = {
"S": ["aA", "bB"],
"A": ["a", "ε"],
"B": ["b"]
}
display_grammar(grammar)