Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(11)  |  Call(9)  |  Derive(0)  |  Import(2)
When Matcher objects are added, they automatically create an AutoSequence,
which will add in future Matcher objects as well.

src/c/h/chomsky-HEAD/test/matchers/test_matcher_addition.py   chomsky(Download)
from chomsky import *
from chomsky.matchers import AutoSequence
 
 
def test_two_additions_repr():
def test_two_additions():
    matcher = Chars('aeiou') + Chars('bcdef')
    test_matcher = AutoSequence(Chars('aeiou'), Chars('bcdef'))
    assert matcher == test_matcher
    assert matcher('uoiaeaiuiobcdef') == ['uoiaeaiuio', 'bcdef']
 
 
def test_two_additions_shorthand():
    matcher = Chars('aeiou') + 'bcdef'
    test_matcher = AutoSequence(Chars('aeiou'), Literal('bcdef'))
def test_two_additions_reverse_shorthand():
    matcher = 'aeiou' + Chars('bcdef')
    test_matcher = AutoSequence(Literal('aeiou'), Chars('bcdef'))
    assert matcher == test_matcher
    assert matcher('aeioubcdef') == ['aeiou', 'bcdef']
def test_three_additions():
    matcher = Chars('aeiou') + Chars('abcde') + Chars('12345')
    test_matcher = AutoSequence(Chars('aeiou'), Chars('abcde'), Chars('12345'))
    assert matcher == test_matcher
 

src/c/h/chomsky-HEAD/test/matchers/test_sequence_matcher.py   chomsky(Download)
from chomsky import *
from chomsky.matchers import AutoSequence
 
 
def test_two_sequences_repr():
def test_three_sequences():
    matcher = Chars('aeiou') + Chars('pqrst') + Chars('12345')
    test_matcher = AutoSequence(Chars('aeiou'), Chars('pqrst'), Chars('12345'))
    assert matcher == test_matcher
    assert matcher('aeioupqrst12345') == ['aeiou', 'pqrst', '12345']
def test_sequence_addition_left():
    matcher = Chars('aeiou') + Sequence(Chars('pqrst'), Chars('12345'))
    test_matcher = AutoSequence(Chars('aeiou'), Sequence(Chars('pqrst'), Chars('12345')))
    assert matcher == test_matcher
    assert matcher('aeioupqrst12345') == ['aeiou', ['pqrst', '12345']]
 
 
def test_sequence_addition_right():
    matcher = Sequence(Chars('aeiou'), Chars('pqrst')) + Chars('12345')
    test_matcher = AutoSequence(Sequence(Chars('aeiou'), Chars('pqrst')), Chars('12345'))