def dirs.go

yaml-for-bend@0.1.1.0 · parse.bend:320

import yaml-for-bend@0.1.1.0/parse.bend as Parse
import Base
import yaml-for-bend@0.1.1.0/token.bend as T

320def dirs.go(toks: List<&2, T.Token>, +user: List<&2, Prefix>, +seen: Bool) -> Dirs:
321  match toks:
322    case Nil{}:
323      Dirs{[], user}
324    case Con{t, +rest}:
325      match t:
326        case T.Token{tok, +start, +end}:
327          match tok:
328            case T.VersionDir{+major, minor}:
329              +bad = Bool.not(Nat.is_eq(major, 1n))
330              when(Dirs, seen, u => DirsBad{T.Error{"found duplicate %YAML directive", start, T.Syntax{}}},
331                u => when(Dirs, bad, u => DirsBad{T.Error{"found incompatible YAML document", start, T.Syntax{}}},
332                  u => dirs.go(rest, user, True{})))
333            case T.TagDir{+h, p}:
334              when(Dirs, is_found(prefix.find(user, h)), u => DirsBad{T.Error{"found duplicate %TAG directive", start, T.Syntax{}}},
335                u => dirs.go(rest, Prefix{h, p} <> user, seen))
336            case _:
337              Dirs{Con{T.Token{tok, start, end}, rest}, user}

Uses (13)

Used by (1)