#NEWLINE# def test_simple_custom_rules( self ) : #NEWLINE# #INDENT# 'Run 2-arg custom-coded rules through their paces.' #NEWLINE# grammar = Grammar ( "\n            bracketed_digit = start digit end\n            start = '['\n            end = ']'" , digit = ( lambda text , pos : ( ( pos + 1 ) if text [ pos ] . isdigit ( ) else None ) ) ) #NEWLINE# s = '[6]' #NEWLINE# eq_ ( grammar . parse ( s ) , Node ( 'bracketed_digit' , s , 0 , 3 , children = [ Node ( 'start' , s , 0 , 1 ) , Node ( 'digit' , s , 1 , 2 ) , Node ( 'end' , s , 2 , 3 ) ] ) )