sql_mojo_parser/__init__.py
def p_postpositions(p):
    '''
    postpositions : LIMIT NUMBER postpositions
                  | ORDER BY colspec postpositions
                  | empty
    '''
    if len(p) > 2:
        if p[1] == "LIMIT":
            postposition = {
                "limit": p[2]
            }
            rest = p[3] if p[3] else {}
        elif p[1:3] == ["ORDER", "BY"]:
            postposition = {
                "order by": p[3]
            }
            rest = p[4] if p[4] else {}
        else:
            breakpoint()
        p[0] = {**postposition, **rest}
    else:
        p[0] = {}
def p_postpositions(p):
    '''
    postpositions : LIMIT NUMBER postpositions
                  | ORDER BY colspec postpositions
                  | empty
    '''
    if len(p) > 2:
        if p[1] == "LIMIT":
            postposition = {
                "limit": p[2]
            }
            rest = p[3] if p[3] else {}
        elif p[1:3] == ["ORDER", "BY"]:
            postposition = {
                "order by": p[3]
            }
            rest = p[4] if p[4] else {}
        else:
            breakpoint()
        p[0] = {**postposition, **rest}
    else:
        p[0] = {}
def p_postpositions ( p ) : if len ( p ) > 2 : if p [ 1 ] == "LIMIT" : postposition = { "limit" : p [ 2 ] } rest = p [ 3 ] if p [ 3 ] else { } elif p [ 1 : 3 ] == [ "ORDER" , "BY" ] : postposition = { "order by" : p [ 3 ] } rest = p [ 4 ] if p [ 4 ] else { } else : breakpoint ( ) p [ 0 ] = { * * postposition , * * rest } else : p [ 0 ] = { }
postpositions : LIMIT NUMBER postpositions
                  | ORDER BY colspec postpositions
                  | empty
postpositions : LIMIT NUMBER postpositions | ORDER BY colspec postpositions | empty