def lhs_names

bolt@1.27.0.0 · src/rules/pedantic/rewalk.bend:484

import bolt@1.27.0.0/src/rules/pedantic/rewalk.bend as Rewalk
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

484# the names a let binds: every name left of its `=` or `<-`
485def lhs_names(nn: Tree.Node, +acc: List<&2, String>) -> List<&2, String>:
486  match nn:
487    case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TEq{}, t, l, c}}, rest}:
488      acc
489    case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TBind{}, t, l, c}}, rest}:
490      acc
491    case Tree.NCons{Tree.Leaf{Lex.Tok{Lex.TName{}, +t, l, c}}, rest}:
492      lhs_names(rest, t <> acc)
493    case Tree.NCons{Tree.Group{open, +kids, close}, rest}:
494      lhs_names(rest, names(kids, acc))
495    case Tree.NCons{h, rest}:
496      lhs_names(rest, acc)
497    case other:
498      acc

Uses (6)

Used by (1)