def plan.lmode
bolt@1.27.0.0 · src/syntax/bind.bend:456
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
456
457def plan.lmode(mode: Mode, kk: Lex.TokKind, +rest: Tree.Node) -> Mode:
458 match mode kk:
459 case MHead{} Lex.TKey{}:
460 MName{}
461 case MTele{+kind} Lex.TOp{}:
462 Bool.pick(Mode, plan.named(rest), MSkip{MTele{kind}}, MTele{kind})
463 case MTele{kind} Lex.TColon{}:
464 MTeleType{kind}
465 case MTeleType{kind} Lex.TComma{}:
466 MTele{kind}
467 case MTeleType{+kind} Lex.TAll{}:
468 Bool.pick(Mode, plan.typed(rest, False{}), MSkip{MTeleType{kind}}, MTeleType{kind})
469 case MLhs{+outer, kind} Lex.TUpper{}:
470 Bool.pick(Mode, plan.group(rest), MLhs{outer, KPat{}}, MLhs{outer, kind})
471 case MLhs{+outer, kind} Lex.TDotted{}:
472 Bool.pick(Mode, plan.group(rest), MLhs{outer, KPat{}}, MLhs{outer, kind})
473 case MLhs{outer, _kind} Lex.TColon{}:
474 MLhsType{outer}
475 case MLhs{_outer, _kind} Lex.TEq{}:
476 MTerm{}
477 case MLhs{_outer, _kind} Lex.TBind{}:
478 MTerm{}
479 case MLhsType{_outer} Lex.TEq{}:
480 MTerm{}
481 case MLhsType{_outer} Lex.TBind{}:
482 MTerm{}
483 case MTerm{} Lex.TAll{}:
484 Bool.pick(Mode, plan.typed(rest, True{}), MSkip{MTerm{}}, MTerm{})
485 case MTerm{} Lex.TAmp{}:
486 Bool.pick(Mode, plan.typed(rest, False{}), MSkip{MTerm{}}, MTerm{})
487 case other _k:
488 plan.skip(other)