Exemplo n.º 1
0
def test_first_maybe():
    eq_(first(maybe(a('x'))), ['x', _EPSYLON])
    eq_(first(maybe(a('x')) + a('y')), ['x', 'y'])
    eq_(first(maybe(a('x')) + maybe(a('y'))), ['x', 'y', _EPSYLON])

    eq_(first(maybe(a('x')) | a('y')), ['x', _EPSYLON, 'y'])
    eq_(first(a('x') | maybe(a('y'))), ['x', 'y', _EPSYLON])
    eq_(first(maybe(a('x')) | maybe(a('y'))), ['x', _EPSYLON, 'y', _EPSYLON])
Exemplo n.º 2
0
def test_first_maybe():
    eq_(first(maybe(a('x'))), ['x', _EPSYLON])
    eq_(first(maybe(a('x')) + a('y')), ['x', 'y'])
    eq_(first(maybe(a('x')) + maybe(a('y'))), ['x', 'y', _EPSYLON])

    eq_(first(maybe(a('x')) | a('y')), ['x', _EPSYLON, 'y'])
    eq_(first(a('x') | maybe(a('y'))), ['x', 'y', _EPSYLON])
    eq_(first(maybe(a('x')) | maybe(a('y'))), ['x', _EPSYLON, 'y', _EPSYLON])
Exemplo n.º 3
0
def test_first_non_pure():
    eq_(first(a('x')), ['x'])
    eq_(first(a('x') + a('y')), ['x'])
    eq_(first(a('x') | a('y')), ['x', 'y'])
Exemplo n.º 4
0
def test_first_many():
    eq_(first(many(a('x'))), ['x', _EPSYLON])
    eq_(first(many(a('x')) + a('y')), ['x', 'y'])
    eq_(first(a('x') + many(a('y'))), ['x'])
Exemplo n.º 5
0
def test_first_non_pure():
    eq_(first(a('x')), ['x'])
    eq_(first(a('x') + a('y')), ['x'])
    eq_(first(a('x') | a('y')), ['x', 'y'])
Exemplo n.º 6
0
def test_first_many():
    eq_(first(many(a('x'))), ['x', _EPSYLON])
    eq_(first(many(a('x')) + a('y')), ['x', 'y'])
    eq_(first(a('x') + many(a('y'))), ['x'])