def plan.binder

bolt@1.27.0.0 · src/syntax/bind.bend:598

import bolt@1.27.0.0/src/syntax/bind.bend as Bind
import Base
import bolt@1.27.0.0/src/syntax/lex.bend as Lex
import bolt@1.27.0.0/src/syntax/tree.bend as Tree

598# the binder a leaf records: its own name, or for `op name`, `@x:` and `&x:`
599# the name after it. A telescope's binder notes its declaration
600def plan.binder(mode: Mode, kk: Lex.TokKind, +tt: String, ll: U32, cc: U32, +rest: Tree.Node) -> Bind:
601  match mode kk:
602    case MCtor{} _k:
603      Bind{tt, ll, cc, KCtor{}, ""}
604    case MName{} _k:
605      Bind{tt, ll, cc, KItem{}, ""}
606    case MTele{kind} Lex.TOp{}:
607      plan.ahead(plan.peek(rest), kind, tt ++ plan.ahead_name(plan.peek(rest)) ++ render(plan.tail(rest)))
608    case MTele{kind} _k:
609      Bind{tt, ll, cc, kind, "" ++ tt ++ render(rest)}
610    case MTeleType{_kind} _k:
611      plan.ahead(plan.peek(rest), KTypeVar{}, "")
612    case MLhs{_outer, kind} _k:
613      Bind{tt, ll, cc, kind, ""}
614    case MTerm{} Lex.TName{}:
615      Bind{tt, ll, cc, KLocal{}, ""}
616    case MTerm{} _k:
617      plan.ahead(plan.peek(rest), KTypeVar{}, "")
618    case _other _k:
619      Bind{tt, ll, cc, KLocal{}, ""}

Uses (13)

Used by (1)