Manual:Operators:Replacement

まんま

>>> from lepl import *
>>> with Override(or_=And, and_=Or):
...     abcd = (Literal('a') & Literal('b')) | ( Literal('c') & Literal('d'))
...     print(abcd.parse_string('ac'))
...     print(abcd.parse_string('ab'))
...
['a', 'c']
None
>>> print(abcd.parse_string('ac'))
['a', 'c']
>>> print(abcd.parse_string('ab'))
None
>>> abcd = (Literal('a') & Literal('b')) | ( Literal('c') & Literal('d'))
>>> print(abcd.parse_string('ac'))
None
>>> print(abcd.parse_string('ab'))
['a', 'b']
>>> word = Letter()[:,...]
>>> with Separator(r'\s+'):
...     sentence = word[1:]
...     sentence.parse_string('hello world')
...
['hello', ' ', 'world']
>>> sentence.parse_string('hello world')
['hello', ' ', 'world']