def METHOD_NAME(grammar):
    grammar_lines = grammar.strip().splitlines()
    grammar_lines = [line.strip() for line in grammar_lines if line != '']
    grammar = {}
    for line in grammar_lines:
        production_name, rules = line.split(' -> ')
        rules = rules.split(' | ')
        productions = []
        for rule in rules:
            rule_parts = rule.strip().split()
            productions.append(rule_parts)
        grammar[production_name] = productions
    return grammar