Exemplo n.º 1
0
def test_star():
    a = Symbol('a*')

    assert a.parse('')[1] == True
    assert a.parse('aa')[0] == ''
    assert a.parse('aa')[1] == 'aa'
    assert a.parse('aab')[0] == 'b'
    assert a.parse('aaba')[0] == 'ba'
Exemplo n.º 2
0
def test_create_symbol():
    """
    old test:
        - manual symbol creation
        - manual parsing
    """
    st = "first second third fourth fifth"

    sw = Symbol('\w+')
    ss = Symbol(' ')

    while st:
        st, curr = sw.parse(st)
        print("parsed: {}".format(curr))
        st, space = ss.parse(st)