Manual:Line-Aware Parsing and the Offside Rule:Indent and Eol Tokens

まんま

>>> from lepl import *
>>> words = Token(Word(Lower()))[:] > list
>>> line = Indent() & words & Eol()
>>> parser = line.string_parser(LineAwareConfiguration(tabsize=4))
>>> parser('\tabc def')
['    ', ['abc', 'def'], '']
>>> parser('\tabc def')
['        ', ['abc', 'def'], '']
>>> parser = line.string_parser(LineAwareConfiguration())
>>> parser('\tabc def')
['        ', ['abc', 'def'], '']
>>> parser(' abc def')
[' ', ['abc', 'def'], '']
>>> parser('  abc def')
['  ', ['abc', 'def'], '']