Lichen

Annotated pyparser/test/test_gendfa.py

893:a13fc2cc28f0
2019-02-04 Paul Boddie Optimised __BOOL to test for integers and to return int values directly. For other value types, __VALUE need not be called once integers have been excluded, and so the attrvalue member can be accessed directly.
paul@437 1
from pyparser.automata import DFA, DEFAULT
paul@437 2
from pyparser.genpytokenize import output
paul@437 3
paul@437 4
def test_states():
paul@437 5
    states = [{"\x00": 1}, {"\x01": 0}]
paul@437 6
    d = DFA(states[:], [False, True])
paul@437 7
    assert output('test', DFA, d, states) == """\
paul@437 8
accepts = [False, True]
paul@437 9
states = [
paul@437 10
    # 0
paul@437 11
    {'\\x00': 1},
paul@437 12
    # 1
paul@437 13
    {'\\x01': 0},
paul@437 14
    ]
paul@437 15
test = automata.pyparser.automata.DFA(states, accepts)
paul@437 16
"""