sql_mojo_parser/__init__.py
def p_expression(p):
    '''
    expression : value
               | expression AND expression
               | expression OR expression
               | expression EQUALS expression
               | NOT expression
               | LPAREN expression RPAREN
    '''
    if len(p) < 3:
        p[0] = p[1]
    elif len(p) == 3:  # not
        p[0] = {
            "op": "not",
            "args": [p[2]],
        }
    elif p[1] == "(":
        p[0] = p[2]
    else:
        p[0] = {
            "op": p[2].lower(),
            "args": [p[1], p[3]],
        }
def p_expression(p):
    '''
    expression : value
               | expression AND expression
               | expression OR expression
               | expression EQUALS expression
               | NOT expression
               | LPAREN expression RPAREN
    '''
    if len(p) < 3:
        p[0] = p[1]
    elif len(p) == 3:  # not
        p[0] = {
            "op": "not",
            "args": [p[2]],
        }
    elif p[1] == "(":
        p[0] = p[2]
    else:
        p[0] = {
            "op": p[2].lower(),
            "args": [p[1], p[3]],
        }
def p_expression ( p ) : if len ( p ) < 3 : p [ 0 ] = p [ 1 ] elif len ( p ) == 3 : # not p [ 0 ] = { "op" : "not" , "args" : [ p [ 2 ] ] , } elif p [ 1 ] == "(" : p [ 0 ] = p [ 2 ] else : p [ 0 ] = { "op" : p [ 2 ] . lower ( ) , "args" : [ p [ 1 ] , p [ 3 ] ] , }
expression : value
               | expression AND expression
               | expression OR expression
               | expression EQUALS expression
               | NOT expression
               | LPAREN expression RPAREN
expression : value | expression AND expression | expression OR expression | expression EQUALS expression | NOT expression | LPAREN expression RPAREN