Beispiel #1
0
def test3():
    rules = {
        'S': ['Aa', 'B', 'c'],
        'B': ['A', 'bb', 'aD'],
        'A': ['a', 'bc', 'B'],
        'D': ['d']
    }
    c = CFG(rules)
    c.start = 'S'
    c.elim_unit()
    c.print_cfg()
    """
Beispiel #2
0
def test4():
    rules = {
        'S': ['XY'],
        'X': ['a'],
        'Y': ['Z', 'b'],
        'Z': ['M'],
        'M': ['N'],
        'N': ['a']
    }
    c = CFG(rules)
    c.start = 'S'
    c.elim_unit()
    c.print_cfg()
    """