Beispiel #1
0
def r(ctx: Context, token: TokenInfo):
    if not ctx.last_op[0].annotation in (A.CLS_BODY_LSQB, A.BODY_LSQB):
        return

    ctx.cache = [token]
    ctx.push_state(State.EXPECT_AUGASSIGN_DASH)
    return actions.StartBuffer()
Beispiel #2
0
def r(ctx: Context, token: TokenInfo):
    directive = token.lxfmt_directive()
    if directive == 'off' and ctx.last_state != State.DISABLED:
        ctx.push_state(State.DISABLED)

    elif directive == 'on' and ctx.last_state == State.DISABLED:
        ctx.pop_state()
Beispiel #3
0
def r(ctx: Context, token: TokenInfo):
    ctx.pop_state()

    ctx.cache.annotation = A.DECL
    ctx.push_state(State.IN_LBDX_CALL)
    token.annotation = A.DECL_LPAR
    ctx.push_op(token)
    return actions.StopBuffer()
Beispiel #4
0
def r(ctx: Context, token: TokenInfo):
    token.annotation = A.CLS_HEAD_LSQB
    ctx.push_op(token)
    ctx.pop_state()
    ctx.push_state(State.IN_LBDX_CLS_HEAD)

    _annotate_clause_declarer(ctx)
    ctx.cache = None
    if ctx.is_buffering():
        return actions.StopBuffer()
Beispiel #5
0
def r(ctx: Context, token: TokenInfo):
    if ctx.pop_op()[0].annotation == A.CLS_BODY_LSQB:
        ctx.pop_state()
        ctx.push_state(State.EXPECT_SUBCLS_DOT)

        sentinel = TokenInfo.new_sentinel_before(token, A.STMT_END)
        ctx.push_ret(sentinel)
        token.annotation = A.CLS_BODY_RSQB
        ctx.push_ret(token)
        return actions.Default(dont_store=True)
Beispiel #6
0
def r(ctx: Context, token: TokenInfo):
    last_state = ctx.pop_state()
    ctx.cache.append(token)

    new_state = {
        State.EXPECT_SUBCLS_NAME: State.EXPECT_CLS_HEAD_OR_BODY_LSQB,
        State.MUST_SUBCLS_NAME_WITH_HEAD: State.EXPECT_CLS_HEAD_LSQB,
        State.MUST_SUBCLS_NAME_WITH_BODY: State.EXPECT_CLS_BODY_LSQB,
    }[last_state]

    ctx.push_state(new_state)
Beispiel #7
0
def r(ctx: Context, token: TokenInfo):

    ctx.pop_state()
    ctx.push_state(State.IN_LBDX_BODY_LIST)
    token.annotation = A.BODY_LSQB
    ctx.push_op(token)
    ctx.push_ret(token)

    sentinel = TokenInfo.new_sentinel_after(token, A.STMT_START)
    ctx.push_ret(sentinel)

    return actions.Default(dont_store=True)
Beispiel #8
0
def r(ctx: Context, token: TokenInfo):
    last_state = ctx.pop_state()

    new_state = {
        State.EXPECT_SUBCLS_DOT: State.EXPECT_SUBCLS_NAME,
        State.MUST_SUBCLS_DOT_WITH_HEAD: State.MUST_SUBCLS_NAME_WITH_HEAD,
        State.MUST_SUBCLS_DOT_WITH_BODY: State.MUST_SUBCLS_NAME_WITH_BODY,
    }[last_state]

    ctx.push_state(new_state)
    ctx.cache = [token]

    return actions.StartBuffer()
Beispiel #9
0
def r(ctx: Context, token: TokenInfo):
    if ctx.is_buffering():
        return actions.StopBuffer(dont_consume=True)

    ctx.pop_state()
    ctx.push_state(State.IN_LBDX_CLS_BODY)
    token.annotation = A.CLS_BODY_LSQB
    ctx.push_op(token)

    _annotate_clause_declarer(ctx)
    ctx.cache = None

    ctx.push_ret(token)
    sentinel = TokenInfo.new_sentinel_after(token, A.STMT_START)
    ctx.push_ret(sentinel)

    return actions.Default(dont_store=True)
Beispiel #10
0
def r(ctx: Context, token: TokenInfo):
    ctx.pop_state()
    ctx.push_state(State.EXPECT_LBDX_NAME)
Beispiel #11
0
def r(ctx: Context, token: TokenInfo):
    ctx.push_state(State.EXPECT_LBDX_LPAR)

    ctx.cache = token
    return actions.StartBuffer()
Beispiel #12
0
def r(ctx: Context, token: TokenInfo):
    ctx.pop_state()
    ctx.push_state(State.EXPECT_AUGASSIGN_ASSIGN)
    return
Beispiel #13
0
def r(ctx: Context, token: TokenInfo):
    if ctx.pop_op()[1] == State.EXPECT_CLS_HEAD_LSQB:
        ctx.pop_state()
        ctx.push_state(State.EXPECT_CLS_BODY_LSQB)
        token.annotation = A.CLS_HEAD_RSQB
Beispiel #14
0
def r(ctx: Context, token: TokenInfo):
    if ctx.pop_op()[1] == State.EXPECT_CLS_HEAD_OR_BODY_LSQB:
        ctx.pop_state()
        ctx.push_state(State.EXPECT_CLS_MAYBE_BODY_LSQB)
Beispiel #15
0
def r(ctx: Context, token: TokenInfo):
    ctx.push_op(token)
    ctx.pop_state()
    ctx.push_state(State.EXPECT_CLS_HEAD_OR_BODY_RSQB)
Beispiel #16
0
def r(ctx: Context, token: TokenInfo):
    ctx.push_state(State.EXPECT_CLS_BODY_LSQB)
    ctx.cache = [token]
    return actions.StartBuffer()
Beispiel #17
0
def r(ctx: Context, token: TokenInfo):
    if ctx.last_op[1] != State.IN_LBDX_CALL:
        return
    ctx.pop_state()
    ctx.push_state(State.EXPECT_LBDX_LSQB)
Beispiel #18
0
def r(ctx: Context, token: TokenInfo):
    ctx.pop_state()
    ctx.push_state(State.MUST_LBDX_LPAR)
Beispiel #19
0
def r(ctx: Context, token: TokenInfo):
    ctx.pop_state()
    ctx.cache.append(token)
    ctx.push_state(State.EXPECT_CLS_HEAD_LSQB)
Beispiel #20
0
def r(ctx: Context, token: TokenInfo):
    ctx.push_state(State.IN_LBDX_LAMBDA)
    token.annotation = A.DECL_LAMBDA