//ww:run-exit 68 package main; type inst_lit = rune; type inst_any = void; type inst_match = bool; type inst = (inst_lit | inst_any | inst_match); type re_t = struct { insts: []inst, n_reps: size }; type capture = struct { content: str, start: size, end: size }; type thread = struct { pc: size, root_capture: capture, failed: bool }; fn step(re: *re_t, ts: *[]thread, i: size) i32 = { match (re.insts[(*ts)[i].pc]) { case let lt: inst_lit => { (*ts)[i].root_capture = capture { content = "hit", start = 2, end = 4 }; (*ts)[i].pc += 1; return 1; }; case inst_any => { (*ts)[i].failed = true; return 2; }; case let m: inst_match => { (*ts)[i].pc += 2; return 3; }; }; return 9; }; export fn main() i32 = { let insts: []inst = []; append(insts, ('a': inst_lit)); let av: inst_any; let v: inst = av; append(insts, v); append(insts, (true: inst_match)); let re: re_t = re_t { insts = insts, n_reps = 0 }; let ts: []thread = []; let z: capture = capture { content = "", start = 0, end = 0 }; append(ts, thread { pc = 0, root_capture = z, failed = false }); if (step(&re, &ts, 0) != 1) { return 1; }; if (ts[0].pc != 1) { return 2; }; if (ts[0].root_capture.start != 2) { return 3; }; if (step(&re, &ts, 0) != 2) { return 4; }; if (!ts[0].failed) { return 5; }; let p: *[]thread = &ts; (*p)[0].pc += 1; if (ts[0].pc != 2) { return 6; }; if (step(&re, &ts, 0) != 3) { return 7; }; if (ts[0].pc != 4) { return 8; }; return 68; };