def METHOD_NAME(p):
    '''rules   : rules rule
               | rule'''
    if len(p) == 2:
        rule = p[1]
    else:
        rule = p[2]
    # Print out a Python equivalent of this rule
    embedded = []      # Embedded actions (a mess)
    embed_count = 0
    rulename = rule[0]
    rulecount = 1
    for r in rule[1]:
        # r contains one of the rule possibilities
        print("def p_%s_%d(p):" % (rulename, rulecount))
        prod = []
        prodcode = ""
        for i in range(len(r)):
            item = r[i]
            if item[0] == '{':    # A code block
                if i == len(r) - 1:
                    prodcode = item
                    break
                else:
                    # an embedded action
                    embed_name = "_embed%d_%s" % (embed_count, rulename)
                    prod.append(embed_name)
                    embedded.append((embed_name, item))
                    embed_count += 1
            else:
                prod.append(item)
        print("    '''%s : %s'''" % (rulename, " ".join(prod)))
        # Emit code
        print_code(prodcode, 4)
        print()
        rulecount += 1
    for e, code in embedded:
        print("def p_%s(p):" % e)
        print("    '''%s : '''" % e)
        print_code(code, 4)
        print()