def depth.pick

bend-toon-codec@0.1.0.0 · src/dline.bend:44

import bend-toon-codec@0.1.0.0/src/dline.bend as Dline
import Base

44# Depth is spaces divided by the indent size. Strict mode refuses tabs in the
45# indentation and a count that is not a multiple. Lenient mode floors the
46# count and reads each leading tab as one indent level.
47def depth.pick(+bad_tab: Bool, +bad_mult: Bool, +no: U32, +depth: U32, +text: String) -> Result<&2, &2, String, DL>:
48  match bad_tab bad_mult:
49    case True{} _:
50      Fail{at(no, "tabs are not allowed in indentation")}
51    case False{} True{}:
52      Fail{at(no, "indentation is not a multiple of the indent size")}
53    case False{} False{}:
54      Done{DL{no, depth, text, False{}}}

Uses (6)

Used by (1)