def relCROperator(s): return a(Token('RelCROperator', s))
def bracket(s): return a(Token('Bracket', s)) >> tokenValue
def colRowOperator(s): return a(Token('ColRowOperator', s))
def operator(s): return a(Token('Operator', s)) >> tokenValue
def parenthesis(s): return a(Token('Parenthesis', s)) >> tokenValue
def relCROperator(s): return a(Token('RelCROperator', s)) pixelOperator = tokenType('PixelOperator')
return some(lambda x: x.type == t) def operator(s): return a(Token('Operator', s)) >> tokenValue def parenthesis(s): return a(Token('Parenthesis', s)) >> tokenValue def bracket(s): return a(Token('Bracket', s)) >> tokenValue eol = a(Token('EndOfLine', ';')) def maybeFlatten(items): ''' Iterate through top-level lists Flatten, only if the element is also a list [[1,2],3,[[4,5]]] -> [1,2,3,[4,5]] ''' new_list = [] for elem in items: # Flatten only if a list if isinstance(elem, list): new_list.extend(elem) else:
def colRowOperator(s): return a(Token('ColRowOperator', s)) def relCROperator(s): return a(Token('RelCROperator', s))
def bracket(s): return a(Token('Bracket', s)) >> tokenValue eol = a(Token('EndOfLine', ';'))
def parenthesis(s): return a(Token('Parenthesis', s)) >> tokenValue def bracket(s): return a(Token('Bracket', s)) >> tokenValue
def operator(s): return a(Token('Operator', s)) >> tokenValue def parenthesis(s): return a(Token('Parenthesis', s)) >> tokenValue
@param t: Name of token type @return: Token matching ''' return some(lambda x: x.type == t) def operator(s): return a(Token('Operator', s)) >> tokenValue def parenthesis(s): return a(Token('Parenthesis', s)) >> tokenValue def bracket(s): return a(Token('Bracket', s)) >> tokenValue eol = a(Token('EndOfLine', ';')) def maybeFlatten(items): ''' Iterate through top-level lists Flatten, only if the element is also a list [[1,2],3,[[4,5]]] -> [1,2,3,[4,5]] ''' new_list = [] for elem in items: # Flatten only if a list if isinstance(elem, list): new_list.extend(elem) else: