diff options
65 files changed, 225 insertions, 223 deletions
diff --git a/bench/runbench.myr b/bench/runbench.myr index 81bf436..ea69f83 100644 --- a/bench/runbench.myr +++ b/bench/runbench.myr @@ -7,7 +7,7 @@ const main = {args : byte[:][:] std.put("Running benchmarks: {} samples per binary\n", Nsamp); tot = 0.0; - for arg in args[1:] + for arg : args[1:] tot = tot + timeit(arg) ;; std.put("total:\t{}s\n", tot); diff --git a/bench/runner.myr b/bench/runner.myr index 8ddc1de..a79c917 100644 --- a/bench/runner.myr +++ b/bench/runner.myr @@ -3,7 +3,7 @@ use std const Nsamp = 10 const main = {args : byte[:][:] - for a in args + for a : args time(a) ;; } diff --git a/lib/bio/bio.myr b/lib/bio/bio.myr index be82867..465cc93 100644 --- a/lib/bio/bio.myr +++ b/lib/bio/bio.myr @@ -354,7 +354,7 @@ const getc = {f } /* ensures we have enough to read a single codepoint in the buffer */ -const ensurecodepoint : (f : file# -> status(std.size)) = {f +const ensurecodepoint = {f var b var len @@ -702,7 +702,7 @@ const geterr = {f -> errtype(e) } -const errtype : (e : std.errno -> ioerr )= {e : std.errno -> ioerr +const errtype = {e : std.errno -> ioerr var errno errno = (e : std.errno) diff --git a/lib/crypto/test/aes.myr b/lib/crypto/test/aes.myr index 46c5a64..1ad9036 100644 --- a/lib/crypto/test/aes.myr +++ b/lib/crypto/test/aes.myr @@ -8,28 +8,28 @@ type aestest = struct ;; const main = { - for tc in ECBVarKey128encvecs + for tc : ECBVarKey128encvecs enctest(tc) ;; - for tc in ECBVarKey192encvecs + for tc : ECBVarKey192encvecs enctest(tc) ;; - for tc in ECBVarKey256encvecs + for tc : ECBVarKey256encvecs enctest(tc) ;; - for tc in ECBVarKey128decvecs + for tc : ECBVarKey128decvecs dectest(tc) ;; - for tc in ECBVarKey192decvecs + for tc : ECBVarKey192decvecs dectest(tc) ;; - for tc in ECBVarKey256decvecs + for tc : ECBVarKey256decvecs dectest(tc) ;; - for tc in ECBVarKey128encbigvecs + for tc : ECBVarKey128encbigvecs bigenctest(tc) ;; - for tc in ECBVarKey128decbigvecs + for tc : ECBVarKey128decbigvecs bigdectest(tc) ;; } diff --git a/lib/crypto/test/chacha20.myr b/lib/crypto/test/chacha20.myr index e9c09f4..7ca349f 100644 --- a/lib/crypto/test/chacha20.myr +++ b/lib/crypto/test/chacha20.myr @@ -848,7 +848,7 @@ const check = {chk crypto.chacha20keysetup(&st, chk.key) crypto.chacha20ivsetup(&st, chk.iv) - for (i, s) in std.byenum(chk.state) + for (i, s) : std.byenum(chk.state) std.assert(st.input[i] == s, "mismatched state\n") ;; diff --git a/lib/crypto/test/util.myr b/lib/crypto/test/util.myr index ceb411c..e6a3211 100644 --- a/lib/crypto/test/util.myr +++ b/lib/crypto/test/util.myr @@ -8,7 +8,7 @@ const hasheq = {got, expected var sb, str sb = std.mksb() - for x in got + for x : got std.sbfmt(sb, "{p=0,w=2,x}", x) ;; str = std.sbfin(sb) diff --git a/lib/date/fmt.myr b/lib/date/fmt.myr index bc57500..c66827b 100644 --- a/lib/date/fmt.myr +++ b/lib/date/fmt.myr @@ -18,14 +18,14 @@ const __init__ = { ][:]) } -/* Always formats in proleptic Gregorian format */ +/* Always formats : proleptic Gregorian format */ const sbfmt = {sb, ap, opts var d : instant var fmt d = std.vanext(ap) fmt = Datetimefmt; - for o in opts + for o : opts match o | ("d", ""): fmt = Datefmt | ("t", ""): fmt = Timefmt diff --git a/lib/date/test/fmt.myr b/lib/date/test/fmt.myr index e0aa610..024c7b6 100644 --- a/lib/date/test/fmt.myr +++ b/lib/date/test/fmt.myr @@ -31,7 +31,7 @@ const main = { d = date.mkinstant(-50000000000*1_000_000, "") eq("385-7-25 07:06:40 +0000", std.bfmt(buf[:], "{D}", d)) - /* date in the bc */ + /* date : the bc */ d = date.mkinstant(-70000000000*1_000_000, "") eq("-249-11-19 19:33:20 +0000", std.bfmt(buf[:], "{D}", d)) diff --git a/lib/date/types.myr b/lib/date/types.myr index 3e3af76..0849052 100644 --- a/lib/date/types.myr +++ b/lib/date/types.myr @@ -4,14 +4,14 @@ pkg date = type instant = struct actual : std.time /* epoch time in microseconds */ tzoff : duration /* timezone offset in microseconds */ - year : int /* year, starting at 0 (ie, 1 BCE) */ - mon : int /* month, [1..12] */ - day : int /* day, [1..31] */ - wday : int /* weekday, [0..6] */ - h : int /* hour: [0..23] */ - m : int /* minute: [0..59] */ - s : int /* second: [0..59] */ - us : int /* microsecond: [0..999,999] */ + year : int /* year, starting at 0 (ie, 1 BCE) */ + mon : int /* month, [1..12] */ + day : int /* day, [1..31] */ + wday : int /* weekday, [0..6] */ + h : int /* hour: [0..23] */ + m : int /* minute: [0..59] */ + s : int /* second: [0..59] */ + us : int /* microsecond: [0..999,999] */ tzname : byte[:] /* current time zone name */ _tzbuf : byte[32] /* current time zone name storage */ ;; diff --git a/lib/date/zoneinfo+posixy.myr b/lib/date/zoneinfo+posixy.myr index 26aa916..69b2e85 100644 --- a/lib/date/zoneinfo+posixy.myr +++ b/lib/date/zoneinfo+posixy.myr @@ -47,7 +47,7 @@ const findtzoff = {tz, tm -> std.option(date.duration) path = std.sldup("/etc/localtime") else path = "" - for z in zonepath + for z : zonepath path = std.pathcat(z, tz) if sys.stat(path, &sb) == 0 goto found diff --git a/lib/escfmt/eschtml.myr b/lib/escfmt/eschtml.myr index 950c8bc..e9aea4a 100644 --- a/lib/escfmt/eschtml.myr +++ b/lib/escfmt/eschtml.myr @@ -19,7 +19,7 @@ const htmlfmt = {sb, ap, args var s : byte[:] s = std.vanext(ap) - for c in std.bychar(s) + for c : std.bychar(s) match c | '&': std.sbputs(sb, "&") | '<': std.sbputs(sb, "<") diff --git a/lib/escfmt/escre.myr b/lib/escfmt/escre.myr index 72eb7ae..39c9a30 100644 --- a/lib/escfmt/escre.myr +++ b/lib/escfmt/escre.myr @@ -19,7 +19,7 @@ const refmt = {sb, ap, args var s : byte[:] s = std.vanext(ap) - for c in std.bychar(s) + for c : std.bychar(s) match c | '|': std.sbputs(sb, "\\|") | '*': std.sbputs(sb, "\\*") diff --git a/lib/escfmt/escsh.myr b/lib/escfmt/escsh.myr index 11f6104..b2388b8 100644 --- a/lib/escfmt/escsh.myr +++ b/lib/escfmt/escsh.myr @@ -20,7 +20,7 @@ const shfmt = {sb, ap, args s = std.vanext(ap) std.sbputb(sb, ('\'' : byte)) - for b in s + for b : s if b == ('\'' : byte) std.sbputs(sb, "'\\''") else diff --git a/lib/escfmt/escurl.myr b/lib/escfmt/escurl.myr index 8ca2f4c..1f1841e 100644 --- a/lib/escfmt/escurl.myr +++ b/lib/escfmt/escurl.myr @@ -19,7 +19,7 @@ const urlfmt = {sb, ap, args var s : byte[:] s = std.vanext(ap) - for b in s + for b : s match (b : char) | ':': std.sbfmt(sb, "%{x}", b) | '/': std.sbfmt(sb, "%{x}", b) diff --git a/lib/inifile/parse.myr b/lib/inifile/parse.myr index 28718f9..e2490c2 100644 --- a/lib/inifile/parse.myr +++ b/lib/inifile/parse.myr @@ -25,12 +25,12 @@ const load = {path } const free = {ini - for ((sect, key), val) in std.byhtkeyvals(ini.elts) + for ((sect, key), val) : std.byhtkeyvals(ini.elts) std.slfree(val) std.slfree(sect) std.slfree(key) ;; - for s in ini.sects + for s : ini.sects std.slfree(s) ;; std.slfree(ini.sects) diff --git a/lib/inifile/test/inifile.myr b/lib/inifile/test/inifile.myr index f3c7a98..ccc43f9 100644 --- a/lib/inifile/test/inifile.myr +++ b/lib/inifile/test/inifile.myr @@ -43,7 +43,7 @@ const itersects = { ini = std.try(inifile.load("test/test.ini")) somesect=0 anothersection=0 - for k in inifile.bysection(ini) + for k : inifile.bysection(ini) match k | "somesect": somesect++ | "another section": anothersection++ diff --git a/lib/inifile/write.myr b/lib/inifile/write.myr index deb3ccc..1c7071d 100644 --- a/lib/inifile/write.myr +++ b/lib/inifile/write.myr @@ -44,7 +44,7 @@ const writeini = {f, ini }) oldsect = "" - for (sect, key) in keys + for (sect, key) : keys std.put("sect={}, oldsect={}\n", sect, oldsect) if !std.sleq(sect, oldsect) bio.put(f, "[{}]\n", sect) diff --git a/lib/json/fmt.myr b/lib/json/fmt.myr index 04867f2..fe29688 100644 --- a/lib/json/fmt.myr +++ b/lib/json/fmt.myr @@ -32,7 +32,7 @@ const eltfmt = {sb, e, ind const jstrfmt = {sb, str std.sbputs(sb, "\"") - for c in str + for c : str match (c : char) | '\x0c': std.sbputs(sb, "\\f") | '\\': std.sbputs(sb, "\\\\") @@ -50,7 +50,7 @@ const arrfmt = {sb, arr, ind sep = "" std.sbputs(sb, "[\n") - for e in arr + for e : arr std.sbputs(sb, sep) indent(sb, ind + 1) eltfmt(sb, e, ind + 1) @@ -66,7 +66,7 @@ const objfmt = {sb, obj, ind sep = "" std.sbputs(sb, "{\n") - for (k, v) in obj + for (k, v) : obj std.sbputs(sb, sep) indent(sb, ind + 1) jstrfmt(sb, k) diff --git a/lib/json/parse.myr b/lib/json/parse.myr index ec22d91..d57d991 100644 --- a/lib/json/parse.myr +++ b/lib/json/parse.myr @@ -51,11 +51,11 @@ const free = {j | &(`Num _): /* nothing */ | &(`Str s): std.slfree(s) | &(`Arr a): - for e in a + for e : a free(e) ;; | &(`Obj o): - for (k, v) in o + for (k, v) : o std.slfree(k) free(v) ;; @@ -124,7 +124,7 @@ const parseobj = {p exit(p) -> `std.Ok std.mk(`Obj membs) :error - for (k, v) in membs + for (k, v) : membs std.slfree(k) free(v) ;; @@ -196,7 +196,7 @@ const parsearr = {p -> std.result(elt#, err) exit(p) -> `std.Ok std.mk(`Arr elts) :error - for e in elts + for e : elts free(e) ;; std.slfree(elts) diff --git a/lib/json/test/parse.myr b/lib/json/test/parse.myr index 4ed65dc..893398d 100644 --- a/lib/json/test/parse.myr +++ b/lib/json/test/parse.myr @@ -94,7 +94,7 @@ const filetest = { var dir, data, path dir = std.try(std.diropen("test/inputs")) - for f in std.byentry(dir) + for f : std.byentry(dir) path = std.pathcat("test/inputs", f) data = std.try(std.slurp(path)) /* 'n' indicates expected failure, 'y' indicates expected success, 'i' indicates implementation defined */ @@ -104,7 +104,7 @@ const filetest = { [.name=f, .fn={ctx match json.parse(data) | `std.Err e: /* ok */ - | `std.Ok r: testr.fail(ctx, "succeeded in parsing malformed json: {}\n", r) + | `std.Ok r: testr.fail(ctx, "succeeded : parsing malformed json: {}\n", r) std.die("hah") ;; }] diff --git a/lib/regex/compile.myr b/lib/regex/compile.myr index 5228d08..edfa3aa 100644 --- a/lib/regex/compile.myr +++ b/lib/regex/compile.myr @@ -85,7 +85,7 @@ const free = {re if re.debug std.htfree(re.astloc) std.slfree(re.pcidx) - for bs in re.traces + for bs : re.traces std.bsfree(bs) ;; std.slfree(re.traces) @@ -128,7 +128,7 @@ const genranges = {re, sl, ast /* generate a trie of ranges */ rt = std.zalloc() - for r in sl + for r : sl /* encode: lo => bounds[loidx] - 1 @@ -226,7 +226,7 @@ const rtinsert = {rt, lo, hi } const rtfree = {rt - for l in rt.link + for l : rt.link rtfree(l) ;; std.slfree(rt.link) @@ -270,7 +270,7 @@ const rangeprogsize = {rt sz = 0 else sz = 2*rt.ranges.len - 1 - for l in rt.link + for l : rt.link sz += rangeprogsize(l) ;; ;; @@ -454,7 +454,7 @@ const dump = {re, t, indent std.put("Chr {}\n", c) | `Ranges rl: std.put("Ranges") - for r in rl + for r : rl for var i = 0; i < indent + 1; i++ std.put(" ") ;; @@ -797,7 +797,7 @@ const negate = {rng neg = [][:] start = 0 next = 0 /* if we have no ranges */ - for r in rng + for r : rng (end, next) = (r[0], r[1]) std.slpush(&neg, [start, end - 1]) start = next + 1 @@ -817,7 +817,7 @@ const merge = {rl ret = [][:] lo = rl[0][0] hi = rl[0][1] - for r in rl[1:] + for r : rl[1:] /* if it overlaps or abuts, merge */ if r[0] <= hi + 1 hi = r[1] diff --git a/lib/regex/interp.myr b/lib/regex/interp.myr index 6c2c68b..c7e8514 100644 --- a/lib/regex/interp.myr +++ b/lib/regex/interp.myr @@ -223,7 +223,7 @@ const run = {re, str, idx, wholestr re.runq = mkthread(re, 0) if re.debug /* The last run could have left things here, since we need this info after the run */ - for bs in re.traces + for bs : re.traces std.bsfree(bs) ;; std.slfree(re.traces) diff --git a/lib/regex/redump.myr b/lib/regex/redump.myr index a69e642..e47b824 100644 --- a/lib/regex/redump.myr +++ b/lib/regex/redump.myr @@ -16,7 +16,7 @@ const main = {args [.opt='v', .desc="dump verbose regex output"] ][:], ]) - for opt in cmd.opts + for opt : cmd.opts match opt | ('v', _): verbose = true | _: std.fatal("Unknown argument") @@ -43,7 +43,7 @@ const main = {args const runall = {re, files - for f in files + for f : files match bio.open(f, bio.Rd) | `std.Ok fd: dump(re, fd) @@ -112,7 +112,7 @@ const showcoverage = {re ;; std.put("\t") - for h in hit + for h : hit if h std.put("^") else diff --git a/lib/std/bigint.myr b/lib/std/bigint.myr index f66659e..45170dd 100644 --- a/lib/std/bigint.myr +++ b/lib/std/bigint.myr @@ -252,7 +252,7 @@ const bigparse = {str fit in one digit. */ v = mkbigint(1) - for c in std.bychar(str) + for c : std.bychar(str) if c == '_' continue ;; diff --git a/lib/std/bitset.myr b/lib/std/bitset.myr index 937e65b..1d846da 100644 --- a/lib/std/bitset.myr +++ b/lib/std/bitset.myr @@ -67,7 +67,7 @@ const bscount = {bs var n n = 0 - for v in bybsvalue(bs) + for v : bybsvalue(bs) n++ ;; -> n diff --git a/lib/std/bytealloc.myr b/lib/std/bytealloc.myr index 6c5d94c..654aa88 100644 --- a/lib/std/bytealloc.myr +++ b/lib/std/bytealloc.myr @@ -56,7 +56,8 @@ type slab = struct nfree : size /* the number of free nodes */ ;; -type chunk = struct /* NB: must be smaller than sizeof(slab) */ +/* NB: must be smaller than sizeof(slab) */ +type chunk = struct next : chunk# /* the next chunk in the free list */ ;; diff --git a/lib/std/dial+posixy.myr b/lib/std/dial+posixy.myr index 15fc58f..386dac5 100644 --- a/lib/std/dial+posixy.myr +++ b/lib/std/dial+posixy.myr @@ -22,6 +22,7 @@ pkg std = a map from service name to a list of (port,proto) pairs in order of preference */ + /* FIXME: implement var services : htab(byte[:], [int, byte[:]][:])# var inited = false diff --git a/lib/std/env+posixy.myr b/lib/std/env+posixy.myr index 3919388..fe73c7e 100644 --- a/lib/std/env+posixy.myr +++ b/lib/std/env+posixy.myr @@ -26,7 +26,7 @@ const getenv = {name var n, env envinit() - for envp in environ + for envp : environ env = cstrconvp(envp) n = min(name.len, env.len) if sleq(name, env[:n]) && sleq(env[n:n+1], "=") @@ -48,7 +48,7 @@ const setenv = {name, val envdup() idx = 0 - for envp in environ + for envp : environ env = cstrconvp(envp) n = min(name.len, env.len) if sleq(name, env[:n]) && sleq(env[n:n+1], "=") diff --git a/lib/std/execvp.myr b/lib/std/execvp.myr index c719e5c..f6696e3 100644 --- a/lib/std/execvp.myr +++ b/lib/std/execvp.myr @@ -21,7 +21,7 @@ const execvp = {cmd, args -> execv(cmd, args) | `None: paths = getpaths() - for p in paths + for p : paths binpath = bfmt(buf[:], "{}/{}", p, cmd) execv(binpath, args) ;; @@ -39,7 +39,7 @@ const execvpe = {cmd, args, env -> execve(cmd, args, env) | `None: paths = getpaths() - for p in paths + for p : paths binpath = bfmt(buf[:], "{}/{}", p, cmd) execve(binpath, args, env) ;; diff --git a/lib/std/fltbits.myr b/lib/std/fltbits.myr index 2a9e8cf..f9afd7a 100644 --- a/lib/std/fltbits.myr +++ b/lib/std/fltbits.myr @@ -24,9 +24,9 @@ const flt64explode = {flt var bits, isneg, mant, exp bits = flt64bits(flt) - isneg = (bits >> 63) != 0 /* msb is sign bit */ + isneg = (bits >> 63) != 0 /* msb is sign bit */ exp = (bits >> 52) & 0x7ff /* exp is in bits [52..63] */ - mant = bits & ((1l << 52) - 1) /* msb is in bits [..51] */ + mant = bits & ((1l << 52) - 1) /* msb is in bits [..51] */ /* add back the implicit bit if this is not a denormal */ if exp != 0 @@ -47,9 +47,9 @@ const flt32explode = {flt var bits, isneg, mant, exp bits = flt32bits(flt) - isneg = (bits >> 31) != 0 /* msb is sign bit */ - exp = (bits >> 22) & 0xff /* exp is in bits [23..30] */ - mant = bits & ((1 << 22) - 1) /* msb is in bits [0..22] */ + isneg = (bits >> 31) != 0 /* msb is sign bit */ + exp = (bits >> 22) & 0xff /* exp is in bits [23..30] */ + mant = bits & ((1 << 22) - 1) /* msb is in bits [0..22] */ /* add back the implicit bit if this is not a denormal */ if exp != 0 diff --git a/lib/std/fmt.myr b/lib/std/fmt.myr index 794218a..e405075 100644 --- a/lib/std/fmt.myr +++ b/lib/std/fmt.myr @@ -216,7 +216,7 @@ const parseparams = {paramstr, optdesc std.fatal("invalid format options {}\n") ;; params = strsplit(paramstr, ",") - for p in params + for p : params /* parse out the key/value pair */ match std.strfind(p, "=") | `std.Some idx: @@ -231,7 +231,7 @@ const parseparams = {paramstr, optdesc found = false /* verify and add the arg */ - for (opt, hasarg) in optdesc + for (opt, hasarg) : optdesc if !std.sleq(opt, o) continue ;; @@ -245,7 +245,7 @@ const parseparams = {paramstr, optdesc ;; if !found std.put("options: \n") - for (opt, hasarg) in optdesc + for (opt, hasarg) : optdesc std.put("\t'{}', hasarg={}\n", opt, hasarg) ;; std.fatal("invalid option '{}' ", o) @@ -427,7 +427,7 @@ const fmtslice = {sb, subap, params ][:]) join = ", " joined = false - for o in opts + for o : opts match o | ("j", j): joined = true @@ -483,7 +483,7 @@ const intparams = {params ("x", false), ("w", true), ("p", true)][:]) - for o in opts + for o : opts match o | ("x", ""): ip.base = 16 | ("w", wid): ip.padto = getint(wid, "fmt: width must be integer") @@ -511,7 +511,7 @@ const strfmt = {sb, str, params ("e", false), ][:]) - for o in opts + for o : opts match o | ("w", wid): w = getint(wid, "fmt: width must be integer") | ("p", pad): p = decode(pad) @@ -523,14 +523,14 @@ const strfmt = {sb, str, params iassert(p >= 0, "pad must be >= 0") std.slfree(opts) if raw - for b in str + for b : str if esc sbputs(sb, "\\x") ;; intfmt(sb, [.padto=2, .padfill='0', .base=16], false, b) ;; elif esc - for b in str + for b : str if isprint(b) sbputb(sb, b) else diff --git a/lib/std/intparse.myr b/lib/std/intparse.myr index e9686b3..18cc478 100644 --- a/lib/std/intparse.myr +++ b/lib/std/intparse.myr @@ -52,7 +52,7 @@ generic doparse = {s, isneg, base -> option(@a::(integral,numeric)) var cv : int32 v = 0 - for c in std.bychar(s) + for c : std.bychar(s) if c == '_' continue ;; diff --git a/lib/std/optparse.myr b/lib/std/optparse.myr index a2cf06c..0569dfc 100644 --- a/lib/std/optparse.myr +++ b/lib/std/optparse.myr @@ -153,7 +153,7 @@ const optdone = {ctx } const optinfo = {ctx, opt - for o in ctx.optdef.opts + for o : ctx.optdef.opts if o.opt == opt -> `Some (o.arg.len != 0, !o.optional, o.dest) ;; @@ -189,13 +189,13 @@ const optusage = {prog, def sb = mksb() std.sbfmt(sb, "usage: {} [-h?", prog) - for o in def.opts + for o : def.opts if o.arg.len == 0 std.sbfmt(sb, "{}", o.opt) ;; ;; std.sbfmt(sb, "] ") - for o in def.opts + for o : def.opts if o.arg.len != 0 std.sbfmt(sb, "[-{} {}] ", o.opt, o.arg) ;; @@ -203,7 +203,7 @@ const optusage = {prog, def std.sbfmt(sb, "{}\n", def.argdesc) std.sbfmt(sb, "\t-h\tprint this help message\n") std.sbfmt(sb, "\t-?\tprint this help message\n") - for o in def.opts + for o : def.opts std.sbfmt(sb, "\t-{}{}{}\t{}\n", o.opt, sep(o.arg), o.arg, o.desc) ;; s = sbfin(sb) diff --git a/lib/std/pathjoin.myr b/lib/std/pathjoin.myr index 2cc2340..eb5e6fd 100644 --- a/lib/std/pathjoin.myr +++ b/lib/std/pathjoin.myr @@ -42,7 +42,7 @@ const pathnorm = {p /* "." is a no-op component, so we drop it. In order to drop a component, we set it to the empty string, - and remove it later on in the code. + and remove it later on. */ for i = 0; i < comps.len; i++ if sleq(comps[i], ".") diff --git a/lib/std/resolve+posixy.myr b/lib/std/resolve+posixy.myr index 50962a7..06250d5 100644 --- a/lib/std/resolve+posixy.myr +++ b/lib/std/resolve+posixy.myr @@ -123,7 +123,7 @@ const loadhosts = { ;; lines = strsplit(h, "\n") - for l in lines + for l : lines /* trim comment */ match strfind(l, "#") | `Some idx: l = l[:idx] @@ -190,7 +190,7 @@ const loadresolv = { ;; lines = strsplit(h, "\n") - for l in lines + for l : lines match strfind(l, "#") | `Some _idx: l = l[:_idx] | `None: @@ -247,7 +247,7 @@ const dnsresolve = {host, rt -> `Err (`Badhost) ;; /* FIXME: Assumption: nameservers is not modified by other threads */ - for ns in nameservers + for ns : nameservers nsrv = dnsconnect(ns) if nsrv >= 0 r = dnsquery(nsrv, host, rt) diff --git a/lib/std/slpush.myr b/lib/std/slpush.myr index 1790073..b09069c 100644 --- a/lib/std/slpush.myr +++ b/lib/std/slpush.myr @@ -10,9 +10,9 @@ generic slpush = {sl, elt slpush relies on implementation details of slgrow for efficiency. Because bucket sizes come in powers of two for all buckets - <= 32k, and we only reallocate when we hit - a bucket boundary, this is effectively - growing the slice by powers of two. + <= 32k, and by powers of 1.5 for larger + slices, this is effectively growing the + slice by powers of two. */ slgrow(sl, sl#.len + 1) sl#[sl#.len - 1] = elt diff --git a/lib/std/test/bitset.myr b/lib/std/test/bitset.myr index 0415be8..13706a6 100644 --- a/lib/std/test/bitset.myr +++ b/lib/std/test/bitset.myr @@ -36,7 +36,7 @@ const main = { std.bsput(bs, 16) std.bsput(bs, 7) std.bsput(bs, 3) - for e in std.bybsvalue(bs) + for e : std.bybsvalue(bs) testr.check(ctx, e == expected[i], "expected[{}] ({}) != {}", i, e, expected[i]) i++ ;; @@ -63,7 +63,7 @@ const mkset = {elts var bs bs = std.mkbs() - for e in elts + for e : elts std.bsput(bs, e) ;; -> bs diff --git a/lib/std/test/bytealloc.myr b/lib/std/test/bytealloc.myr index e6d87d6..7da7de8 100644 --- a/lib/std/test/bytealloc.myr +++ b/lib/std/test/bytealloc.myr @@ -3,9 +3,9 @@ use std const main = { var a : byte#[1000] - for sz in [10, 100, 1000, 10000, 10000] + for sz : [10, 100, 1000, 10000, 10000] std.put("sz: {}\n", sz) - for cnt in [1, 10, 100] + for cnt : [1, 10, 100] std.put("cnt: {}\n", cnt) /* alloc forwards, dealloc forwards */ for var i = 0; i < cnt; i++ diff --git a/lib/std/test/fmt.myr b/lib/std/test/fmt.myr index e8e3f22..67ba2e4 100644 --- a/lib/std/test/fmt.myr +++ b/lib/std/test/fmt.myr @@ -154,7 +154,7 @@ const pairfmt = {sb, ap, opts x = std.vanext(ap) std.sbfmt(sb, "formatted a pair: [{}, {}]", x.x, x.y) - for opt in opts + for opt : opts std.sbputc(sb, ' ') match opt | ("x", val): std.sbfmt(sb, "x={}", val) diff --git a/lib/std/test/ipparse.myr b/lib/std/test/ipparse.myr index 1ea14db..fd6140a 100644 --- a/lib/std/test/ipparse.myr +++ b/lib/std/test/ipparse.myr @@ -69,11 +69,11 @@ const eq = {ip, expected if !std.sleq(p, e) std.fput(1, "misparsed ip {}\n", ip) std.put("parsed: ") - for b in p + for b : p std.put("{x}, ", b) ;; std.put("\nexpected: ") - for b in e + for b : e std.put("{x}, ", b) ;; std.put("\n") diff --git a/lib/std/test/iterutil.myr b/lib/std/test/iterutil.myr index dfa46fa..1d45a4d 100644 --- a/lib/std/test/iterutil.myr +++ b/lib/std/test/iterutil.myr @@ -4,21 +4,21 @@ const main = { var n n = 0 - for (x, i) in std.byenum([1,3,5,7,9][:]) + for (x, i) : std.byenum([1,3,5,7,9][:]) std.assert(x == n, "invalid enum idx {}", x) std.assert(i == n*2 + 1, "invalid enum val {}", i) n++ ;; n = 0 - for (a, b) in std.byzip([0,2,4,6,8][:], [2,4][:]) + for (a, b) : std.byzip([0,2,4,6,8][:], [2,4][:]) std.assert(a == n*2, "invalid val from a: {}", a) std.assert(b == n*2 + 2, "invalid val from b: {}", b) n++ ;; n = 0 - for x in std.byreverse([3, 2, 1, 0][:]) + for x : std.byreverse([3, 2, 1, 0][:]) std.assert(x == n, "invalid reversed value {}, expected {}", x, n) n++ ;; diff --git a/lib/std/test/striter.myr b/lib/std/test/striter.myr index 2684f8d..90b38ed 100644 --- a/lib/std/test/striter.myr +++ b/lib/std/test/striter.myr @@ -6,13 +6,13 @@ const main = { var i i = 0 - for c in std.bychar("abc") + for c : std.bychar("abc") std.assert(chars[i++] == c, "wrong char") ;; std.assert(i == chars.len, "wrong split count") i = 0 - for sp in std.bysplit("foo+++bar", "++") + for sp : std.bysplit("foo+++bar", "++") std.assert(std.streq(splits[i++], sp), "wrong split {}", sp) ;; std.assert(i == splits.len, "wrong split count") diff --git a/lib/sys/sys+freebsd-x64.myr b/lib/sys/sys+freebsd-x64.myr index e7349a5..bfe0d54 100644 --- a/lib/sys/sys+freebsd-x64.myr +++ b/lib/sys/sys+freebsd-x64.myr @@ -108,10 +108,10 @@ pkg sys = type utsname = struct system : byte[32] - node : byte[32] - release : byte[32] - version : byte[32] - machine : byte[32] + node : byte[32] + release : byte[32] + version : byte[32] + machine : byte[32] ;; type sockaddr = struct @@ -146,9 +146,9 @@ pkg sys = type sockaddr_storage = struct len : byte fam : sockfam - __pad1 : byte[6] - __align : int64 - __pad2 : byte[112] + __pad1 : byte[6] + __align : int64 + __pad2 : byte[112] ;; type dirent = struct @@ -304,25 +304,25 @@ pkg sys = const Maxpathlen : size = 1024 /* fcntl constants */ - const Fdupfd : fcntlcmd = 0 /* duplicate file descriptor */ - const Fgetfd : fcntlcmd = 1 /* get file descriptor flags */ - const Fsetfd : fcntlcmd = 2 /* set file descriptor flags */ - const Fgetfl : fcntlcmd = 3 /* get file status flags */ - const Fsetfl : fcntlcmd = 4 /* set file status flags */ - const Fgetown : fcntlcmd = 5 /* get SIGIO/SIGURG proc/pgrp */ - const Fsetown : fcntlcmd = 6 /* set SIGIO/SIGURG proc/pgrp */ - const Fogetlk : fcntlcmd = 7 /* get record locking information */ - const Fosetlk : fcntlcmd = 8 /* set record locking information */ - const Fosetlkw : fcntlcmd = 9 /* F_SETLK; wait if blocked */ - const Fdup2fd : fcntlcmd = 10 /* duplicate file descriptor to arg */ - const Fgetlk : fcntlcmd = 11 /* get record locking information */ - const Fsetlk : fcntlcmd = 12 /* set record locking information */ - const Fsetlkw : fcntlcmd = 13 /* F_SETLK; wait if blocked */ - const Fsetlk_remote : fcntlcmd = 14 /* debugging support for remote locks */ - const Freadahead : fcntlcmd = 15 /* read ahead */ - const Frdahead : fcntlcmd = 16 /* Darwin compatible read ahead */ - const Fdupfd_cloexec : fcntlcmd = 17 /* Like F_DUPFD, but FD_CLOEXEC is set */ - const Fdup2fd_cloexec : fcntlcmd = 18 /* Like F_DUP2FD, but FD_CLOEXEC is set */ + const Fdupfd : fcntlcmd = 0 /* duplicate file descriptor */ + const Fgetfd : fcntlcmd = 1 /* get file descriptor flags */ + const Fsetfd : fcntlcmd = 2 /* set file descriptor flags */ + const Fgetfl : fcntlcmd = 3 /* get file status flags */ + const Fsetfl : fcntlcmd = 4 /* set file status flags */ + const Fgetown : fcntlcmd = 5 /* get SIGIO/SIGURG proc/pgrp */ + const Fsetown : fcntlcmd = 6 /* set SIGIO/SIGURG proc/pgrp */ + const Fogetlk : fcntlcmd = 7 /* get record locking information */ + const Fosetlk : fcntlcmd = 8 /* set record locking information */ + const Fosetlkw : fcntlcmd = 9 /* F_SETLK; wait if blocked */ + const Fdup2fd : fcntlcmd = 10 /* duplicate file descriptor to arg */ + const Fgetlk : fcntlcmd = 11 /* get record locking information */ + const Fsetlk : fcntlcmd = 12 /* set record locking information */ + const Fsetlkw : fcntlcmd = 13 /* F_SETLK; wait if blocked */ + const Fsetlk_remote : fcntlcmd = 14 /* debugging support for remote locks */ + const Freadahead : fcntlcmd = 15 /* read ahead */ + const Frdahead : fcntlcmd = 16 /* Darwin compatible read ahead */ + const Fdupfd_cloexec : fcntlcmd = 17 /* Like F_DUPFD, but FD_CLOEXEC is set */ + const Fdup2fd_cloexec : fcntlcmd = 18 /* Like F_DUP2FD, but FD_CLOEXEC is set */ /* return value for a failed mapping */ const Mapbad : byte# = (-1 : byte#) diff --git a/lib/sys/sys+netbsd-x64.myr b/lib/sys/sys+netbsd-x64.myr index 94073e1..c13d88a 100644 --- a/lib/sys/sys+netbsd-x64.myr +++ b/lib/sys/sys+netbsd-x64.myr @@ -90,7 +90,7 @@ pkg sys = mtime : timespec /* time of last data modification */ ctime : timespec /* time of last file status change */ btime : timespec /* time of creation */ - size : uint64 /* file size, in bytes */ + size : uint64 /* file size in bytes */ blocks : uint64 /* blocks allocated for file */ blksize : uint32 /* optimal blocksize for I/O */ flags : uint32 /* user defined flags for file */ diff --git a/lib/testr/testr.myr b/lib/testr/testr.myr index 2c43449..22a271c 100644 --- a/lib/testr/testr.myr +++ b/lib/testr/testr.myr @@ -22,7 +22,7 @@ pkg testr = const run = {specs std.put("MTEST {}\n", specs.len) - for s in specs + for s : specs runspec(&s) ;; } diff --git a/mbld/build.myr b/mbld/build.myr index 7628529..61ea0c3 100644 --- a/mbld/build.myr +++ b/mbld/build.myr @@ -16,7 +16,7 @@ pkg bld = ;; const buildall = {b - for tn in b.all + for tn : b.all if std.hthas(b.built, tn) continue ;; @@ -42,7 +42,7 @@ const buildtarg = {b, targ depset = std.mkht(std.strhash, std.streq) addeps(b, targ, depset) - for tn in b.all + for tn : b.all if std.hthas(b.built, tn) || !std.hthas(depset, tn) continue ;; @@ -75,11 +75,11 @@ const addeps = {b, targ, depset std.htput(depset, targ, true) match gettarg(b.targs, targ) | `Bin bt: - for (dir, lib, targname) in bt.libdeps + for (dir, lib, targname) : bt.libdeps addeps(b, targname, depset) ;; | `Lib lt: - for (dir, lib, targname) in lt.libdeps + for (dir, lib, targname) : lt.libdeps addeps(b, targname, depset) ;; | _: @@ -87,7 +87,7 @@ const addeps = {b, targ, depset } const genall = {b - for tn in b.all + for tn : b.all match gettarg(b.targs, tn) | `Gen gt: runin(b, gt.cmd, gt.dir) | _: /* skip */ @@ -173,7 +173,7 @@ const buildlib = {b, targ const genfiles = {b, gt setdir(b, gt.dir) - for out in gt.out + for out : gt.out if !std.fexists(out) || !allfresh(gt.deps, out) run(gt.cmd) break @@ -182,7 +182,7 @@ const genfiles = {b, gt } const addincludes = {b, targ - for (inc, lib, subtarg) in targ.libdeps + for (inc, lib, subtarg) : targ.libdeps if !hasinc(targ.incpath, inc) std.slput(&targ.incpath, 0, inc) ;; @@ -190,7 +190,7 @@ const addincludes = {b, targ } const hasinc = {path, t - for e in path + for e : path if std.sleq(e, t) -> true ;; @@ -210,7 +210,7 @@ const builddep = {b, dg, out, incs match std.htget(dg.deps, out) | `std.Some deps: - for d in deps + for d : deps if std.sleq(out, d) /* if an input generates itself (eg, object files), we @@ -259,7 +259,7 @@ const compile = {dg, src, incs cmd = [][:] if std.hassuffix(src, ".myr") std.slpush(&cmd, opt_mc) - for inc in incs + for inc : incs std.slpush(&cmd, "-I") std.slpush(&cmd, inc) ;; @@ -271,7 +271,7 @@ const compile = {dg, src, incs std.slfree(cmd) elif std.hassuffix(src, ".s") o = srcswapsuffix(src, config.Objsuffix) - for c in config.Ascmd + for c : config.Ascmd std.slpush(&cmd, c) ;; std.slpush(&cmd,"-o") @@ -286,7 +286,7 @@ const compile = {dg, src, incs std.slpush(&cmd,"-o") std.slpush(&cmd, o) std.slpush(&cmd, src) - for flg in std.htgetv(dg.cflags, src, [][:]) + for flg : std.htgetv(dg.cflags, src, [][:]) std.slpush(&cmd, flg) ;; run(cmd) @@ -303,7 +303,7 @@ const linkbin = {dg, bin, srcfiles, ldscript, rt, incs, extlibs cmd = [][:] /* ld -o bin */ - for c in config.Linkcmd + for c : config.Linkcmd std.slpush(&cmd, std.sldup(c)) ;; std.slpush(&cmd, std.sldup(bin)) @@ -323,7 +323,7 @@ const linkbin = {dg, bin, srcfiles, ldscript, rt, incs, extlibs ;; /* input.o list.o... */ - for f in srcfiles + for f : srcfiles std.slpush(&cmd, srcswapsuffix(f, config.Objsuffix)) ;; @@ -332,7 +332,7 @@ const linkbin = {dg, bin, srcfiles, ldscript, rt, incs, extlibs /* add extra libs */ - for l in dg.extlibs + for l : dg.extlibs std.slpush(&cmd, std.fmt("-l{}", l)) ;; @@ -354,11 +354,11 @@ const archivelib = {dg, lib, files, incs var obj cmd = [][:] - for c in config.Arcmd + for c : config.Arcmd std.slpush(&cmd, std.sldup(c)) ;; std.slpush(&cmd, std.fmt("lib{}.a", lib)) - for f in files + for f : files obj = srcswapsuffix(f, config.Objsuffix) std.slpush(&cmd, obj) ;; @@ -375,14 +375,14 @@ const mergeuse = {dg, lib, files, incs std.slpush(&cmd, std.fmt("lib{}.use", lib)) std.slpush(&cmd, std.sldup("-p")) std.slpush(&cmd, std.sldup(lib)) - for f in files + for f : files if std.hassuffix(f, ".myr") std.slpush(&cmd, srcswapsuffix(f, ".use")) elif !std.hassuffix(f, ".s") && !std.hassuffix(f, ".glue.c") std.fatal("unknown file type for {}\n", f) ;; ;; - for l in dg.extlibs + for l : dg.extlibs std.slpush(&cmd, std.fmt("-l{}", l)) ;; run(cmd) @@ -397,7 +397,7 @@ const addlibs = {cmd, libgraph, incs /* -L incpath... */ if !config.Directlib - for inc in incs + for inc : incs std.slpush(&cmd, std.fmt("-L{}", inc)) ;; ;; @@ -407,7 +407,7 @@ const addlibs = {cmd, libgraph, incs marked = std.mkht(std.strhash, std.streq) head = cmd.len - for lib in libs + for lib : libs cmd = visit(cmd, head, libgraph, lib, looped, marked, incs) ;; @@ -422,7 +422,7 @@ const visit = {cmd, head, g, lib, looped, marked, incs ;; std.htput(looped, lib, true) - for dep in std.htgetv(g, lib, [][:]) + for dep : std.htgetv(g, lib, [][:]) cmd = visit(cmd, head, g, dep, looped, marked, incs) ;; std.htdel(looped, lib) @@ -440,7 +440,7 @@ const putlib = {cmd, head, lib, incs | `std.None: mbldput("in path: ") sep = "" - for inc in incs + for inc : incs mbldput("\t{}{}\n", sep, inc) sep = ", " ;; @@ -456,7 +456,7 @@ const findlib = {lib, incs var sl, p sl = std.bfmt(buf[:], "lib{}.a", lib) - for i in incs + for i : incs p = std.pathcat(i, sl) if std.fexists(p) -> `std.Some p @@ -476,7 +476,7 @@ const freshlibs = {targ, output, libgraph var libs libs = std.htkeys(libgraph) - for l in libs + for l : libs match findlib(l, targ.incpath) | `std.Some lib: if !isfresh(lib, output) @@ -487,7 +487,7 @@ const freshlibs = {targ, output, libgraph | `std.None: std.fput(1, "{}: could not find library lib{}.a\n", targ.name, l) std.fput(1, "searched:\n") - for inc in targ.incpath + for inc : targ.incpath std.fput(1, "\t{}\n", inc) ;; std.fput(1, "\t{}/{}\n", opt_instbase, config.Libpath) @@ -499,7 +499,7 @@ const freshlibs = {targ, output, libgraph } const allfresh = {deps, out - for d in deps + for d : deps if !isfresh(d, out) -> false ;; diff --git a/mbld/clean.myr b/mbld/clean.myr index 1e317fe..234d980 100644 --- a/mbld/clean.myr +++ b/mbld/clean.myr @@ -14,14 +14,14 @@ pkg bld = ;; const cleanall = {b - for tn in b.all + for tn : b.all match gettarg(b.targs, tn) | `Bin bt: cleanup(b, bt, bt.inputs) | `Lib lt: cleanup(b, lt, lt.inputs) | `Gen gt: - for f in gt.out + for f : gt.out if !gt.durable && std.remove(f) mbldput("\tclean {}\n", f) ;; @@ -35,7 +35,7 @@ const cleanall = {b } const clean = {b, targ - for tn in b.all + for tn : b.all match gettarg(b.targs, tn) | `Bin bt: if std.sleq(bt.name, targ) @@ -46,7 +46,7 @@ const clean = {b, targ cleanup(b, lt, lt.inputs) ;; | `Gen gt: - for f in gt.out + for f : gt.out if !gt.durable && std.remove(f) mbldput("\tclean {}\n", f) ;; @@ -74,12 +74,12 @@ const cleanup = {b, targ, leaves setdir(b, targ.dir) dg = myrdeps(b, targ, true, true) mchammer_files = std.mkht(std.strhash, std.streq) - for l in leaves + for l : leaves std.htput(mchammer_files, l, true) ;; keys = std.htkeys(dg.deps) - for k in keys + for k : keys if !std.htgetv(mchammer_files, k, false) && std.remove(k) mbldput("\tclean {}\n", k) ;; diff --git a/mbld/deps.myr b/mbld/deps.myr index 506fffa..e501983 100644 --- a/mbld/deps.myr +++ b/mbld/deps.myr @@ -111,7 +111,7 @@ const swapall = {srcs, suff var sl sl = [][:] - for s in srcs + for s : srcs std.slpush(&sl, srcswapsuffix(s, suff)) ;; -> sl @@ -125,8 +125,8 @@ const dumpgraph = {dg ;; keys = std.htkeys(dg.deps) mbldput("digraph dg {{\n") - for k in keys - for v in std.htgetv(dg.deps, k, ["WTFUNKNOWN!"][:]) + for k : keys + for v : std.htgetv(dg.deps, k, ["WTFUNKNOWN!"][:]) mbldput("\t\"{}\" -> \"{}\";\n", k, v) ;; ;; @@ -143,14 +143,14 @@ const srcdeps = {b, ds, g, path, obj, usefile std.slpush(&ds.depstk, path) if std.htgetv(g.seen, path, false) std.fput(1, "dependency loop involving {}:\n", path) - for d in ds.depstk + for d : ds.depstk std.fput(1, "\t{}\n", d) ;; std.exit(1) ;; deps = getdeps(b, ds, path, std.dirname(path)) std.htput(g.seen, path, true) - for d in deps + for d : deps match d | `Lib (lib, lnum): /* @@ -233,7 +233,7 @@ const getcflags = {ln, cflags, libs | `std.None: | `std.Some m: flags = std.strtok(m[1]) - for fl in flags + for fl : flags std.slpush(&cflags, std.sldup(fl)) ;; std.slfree(flags) @@ -244,7 +244,7 @@ const getcflags = {ln, cflags, libs | `std.None: | `std.Some m: flags = std.strtok(m[1]) - for fl in flags + for fl : flags std.slpush(&libs, std.sldup(fl)) ;; std.slfree(flags) @@ -358,7 +358,7 @@ const scrapelibs = {dg, lib, incs ;; bio.close(f) std.htput(dg.libs, lib, deps) - for dep in deps + for dep : deps scrapelibs(dg, dep, incs) ;; } @@ -366,7 +366,7 @@ const scrapelibs = {dg, lib, incs const openlib = {lib, incs var path, libname - for p in incs + for p : incs libname = std.fmt("lib{}.use", lib) path = std.pathjoin([p, libname][:]) std.slfree(libname) @@ -399,7 +399,7 @@ const openlib = {lib, incs ;; std.fput(std.Err, "could not find library {}\n", lib) std.fput(std.Err, "search path is:\n") - for p in incs + for p : incs std.fput(std.Err, "\t{}\n", p) ;; std.fput(std.Err, "\t{}\n", config.Libpath) diff --git a/mbld/install.myr b/mbld/install.myr index 82e6777..0d8352f 100644 --- a/mbld/install.myr +++ b/mbld/install.myr @@ -26,7 +26,7 @@ const movetargs = {b, rm var libarchive, libuse var pfx - for tn in b.all + for tn : b.all match gettarg(b.targs, tn) | `Bin bt: if bt.install && !bt.istest @@ -42,7 +42,7 @@ const movetargs = {b, rm std.slfree(libuse) ;; | `Data dt: - for blob in dt.blobs + for blob : dt.blobs if dt.path.len == 0 pfx = std.pathcat(config.Sharepath, dt.name) movefile(b, rm, dt.dir, blob, pfx, 0o644) @@ -57,7 +57,7 @@ const movetargs = {b, rm /* nothing to do */ | `Man mt: /* FIXME: figure out man section by number */ - for m in mt.pages + for m : mt.pages moveman(b, rm, mt.dir, m) ;; ;; diff --git a/mbld/main.myr b/mbld/main.myr index 10d3946..61f7ba8 100644 --- a/mbld/main.myr +++ b/mbld/main.myr @@ -46,7 +46,7 @@ const main = {args : byte[:][:] ok = true bld.initopts() - for opt in cmd.opts + for opt : cmd.opts match opt | ('S', ""): bld.opt_genasm = true | ('I', arg): std.slpush(&bld.opt_incpaths, arg) @@ -77,7 +77,7 @@ const main = {args : byte[:][:] ;; ;; - for (e, v) in config.Env + for (e, v) : config.Env std.setenv(e, v) ;; @@ -100,7 +100,7 @@ const main = {args : byte[:][:] if cmd.args.len == 0 bld.buildall(b) else - for c in cmd.args + for c : cmd.args match c | "all": r = bld.buildall(b) | "gen": r = bld.genall(b) diff --git a/mbld/opts.myr b/mbld/opts.myr index e753dcf..ffd9595 100644 --- a/mbld/opts.myr +++ b/mbld/opts.myr @@ -84,7 +84,7 @@ const parseversion = {v i = 0 a = [0, 0, 0] - for e in std.bysplit(v, ".") + for e : std.bysplit(v, ".") match std.intparse(e) | `std.Some n: a[i++] = n | `std.None: continue diff --git a/mbld/parse.myr b/mbld/parse.myr index 614a0a2..2cf2446 100644 --- a/mbld/parse.myr +++ b/mbld/parse.myr @@ -43,7 +43,7 @@ const load = {b ok = loadall(b, b.bldfile, "", sel) targs = sysselfin(sel) - for (name, targ) in targs + for (name, targ) : targs std.slpush(&b.all, name) std.htput(b.targs, name, targ) ;; @@ -62,11 +62,11 @@ const loadall = {b, path, dir, sel p = mkparser(path, dir, b.basedir, sel) ok = bld.parse(b, p, "") - for t in p.targs + for t : p.targs setopts(p, t) ;; - for sub in p.subdirs + for sub : p.subdirs subbld = std.pathcat(sub, "bld.sub") subproj = std.pathcat(sub, "bld.proj") /* @@ -115,11 +115,11 @@ const setmyropt = {p, t ;; std.sljoin(&t.incpath, p.incpath) - for l in p.libdeps + for l : p.libdeps libdep = libpath(p, l) std.slpush(&t.libdeps, libdep) ;; - for l in p.tstdeps + for l : p.tstdeps tstdep = libpath(p, l) std.slpush(&t.tstdeps, tstdep) ;; @@ -206,7 +206,7 @@ const sortdeps = {b all = [][:] looped = std.mkht(std.strhash, std.streq) marked = std.mkht(std.strhash, std.streq) - for dep in b.all + for dep : b.all match gettarg(b.targs, dep) | `Bin _: all = visit(all, b, "all", dep, looped, marked) | `Lib _: all = visit(all, b, "all", dep, looped, marked) @@ -226,7 +226,7 @@ const visit = {all, b, parent, targ, looped, marked ;; std.htput(looped, targ, true) - for (dir, lib, dep) in getdeps(b, parent, targ) + for (dir, lib, dep) : getdeps(b, parent, targ) all = visit(all, b, targ, dep, looped, marked) ;; std.htdel(looped, targ) @@ -311,7 +311,7 @@ const subtarget = {b, p var subs subs = anontarget(p, "sub") - for s in subs + for s : subs std.slpush(&p.subdirs, std.pathcat(p.fdir, s)) ;; } @@ -361,7 +361,7 @@ const cmdtarget = {b, p, cmd, iscmd istest = false deplist = [][:] tags = [][:] - for elt in attrs + for elt : attrs match elt | ("durable", ""): durable = true | ("test", ""): istest = true @@ -384,7 +384,7 @@ const cmdtarget = {b, p, cmd, iscmd .cmd=cmdlist, .tags=tags, ]) - for o in outlist + for o : outlist if iscmd addtarg(p, b, o, gt.tags, `Cmd gt) else @@ -429,7 +429,7 @@ const myrtarget = {b, p, targ match inputlist(p) | `std.Some (wl, libs): libdeps = libs - for w in wl + for w : wl sysseladd(fsel, w) ;; inputs = sysselfin(fsel) @@ -449,7 +449,7 @@ const myrtarget = {b, p, targ tags = [][:] istest = false tstdeps = [][:] - for elt in attrs + for elt : attrs match elt | ("ldscript", lds): ldscript = std.sldup(lds) | ("runtime", rt): runtime = std.sldup(rt) @@ -519,7 +519,7 @@ const datatarget = {b, p, targ ;; tags = [][:] - for elt in attrs + for elt : attrs match elt | ("tag", tag): std.slpush(&tags, tag) | ("path", pathdir): path = pathdir diff --git a/mbld/subtest.myr b/mbld/subtest.myr index 5f0668f..557746d 100644 --- a/mbld/subtest.myr +++ b/mbld/subtest.myr @@ -75,7 +75,7 @@ const showtests = {b, cmd, failed, f, log, ntests curtest = "" nresults = 0 mbldput("\n") - for ln in bio.byline(f) + for ln : bio.byline(f) ln = std.strstrip(ln) match testhead(ln) | `std.None: @@ -127,7 +127,7 @@ const checktests = {ntests, nresults const starttest = {curtest, t if curtest#.len != 0 - std.fatal("malformed input: test {} nested in {}\n", t, curtest) + std.fatal("malformed input in test {} nested : {}\n", t, curtest) ;; mbldput("\trun {}:\t", std.strstrip(t)) curtest# = t diff --git a/mbld/syssel.myr b/mbld/syssel.myr index 0aea817..09574d3 100644 --- a/mbld/syssel.myr +++ b/mbld/syssel.myr @@ -63,7 +63,7 @@ generic sysseladdlist = {syssel, base, attrs, val var nmatch, curbest, n, v nmatch = 0 - for a in attrs + for a : attrs match std.strfind(a, ":") | `std.Some i: n = a[:i] @@ -106,7 +106,7 @@ generic sysselfin = {syssel keys = std.htkeys(syssel._match) ret = [][:] - for k in keys + for k : keys nmatch = std.htgetv(syssel._match, k, -1) if nmatch == -1 std.fatal("{}:{}: target {}, no applicable file for '{}'\n", \ @@ -192,7 +192,7 @@ const word = {data } const tag = {sa, tags - for t in tags + for t : tags std.htput(sa, t, (-1, -1, -1)) ;; } diff --git a/mbld/test.myr b/mbld/test.myr index a6a35f7..16ab59f 100644 --- a/mbld/test.myr +++ b/mbld/test.myr @@ -27,14 +27,14 @@ const test = {b tests = [][:] buildall(b) setdir(b, "") - for tn in b.all + for tn : b.all match gettarg(b.targs, tn) | `Bin bt: std.sljoin(&tests, buildtests(b, bt)) | `Lib lt: std.sljoin(&tests, buildtests(b, lt)) | _: /* nothing */ ;; ;; - for tn in b.all + for tn : b.all match gettarg(b.targs, tn) | `Bin t: if !t.istest @@ -58,14 +58,14 @@ const test = {b ok = true failed = [][:] - for (c, dir) in tests + for (c, dir) : tests setdir(b, dir) if !runtest(b, c, &failed) ok = false ;; ;; - for (bin, dir) in tests + for (bin, dir) : tests freecmd(bin) std.slfree(dir) ;; @@ -74,7 +74,7 @@ const test = {b ;; printfailed(failed) - for f in failed + for f : failed std.slfree(f) ;; if ok @@ -90,7 +90,7 @@ const test = {b const printfailed = {failed if failed.len > 0 mbldput("FAILURES: {}\n", failed.len) - for t in failed + for t : failed mbldput("\t{}\n", t) ;; ;; @@ -100,14 +100,14 @@ const dupcmd = {cmd var ret ret = [][:] - for c in cmd + for c : cmd std.slpush(&ret, std.sldup(c)) ;; -> ret } const freecmd = {cmd - for c in cmd + for c : cmd std.slfree(c) ;; std.slfree(cmd) @@ -119,7 +119,7 @@ const buildtests = {b, targ tests = [][:] setdir(b, targ.dir) - for s in targ.inputs + for s : targ.inputs match testpath(s) | `std.None: /* nothing to do */ | `std.Some path: @@ -152,7 +152,7 @@ const runtest = {b, cmd, failed var sub mbldput("run") - for c in cmd + for c : cmd p = std.pathcat(b.curdir, c) mbldput(" {}", p) std.slfree(p) diff --git a/mbld/util.myr b/mbld/util.myr index 5cec15c..9b561c5 100644 --- a/mbld/util.myr +++ b/mbld/util.myr @@ -51,7 +51,7 @@ const printcmd = {lst if lst.len > 0 mbldput("\t") mbldput("{}\t", lst[0]) - for l in lst[1:] + for l : lst[1:] mbldput("{} ", l) ;; ;; @@ -111,7 +111,7 @@ const srcswapsuffix = {src, new } const strlistfree = {sl - for s in sl + for s : sl std.slfree(s) ;; std.slfree(sl) diff --git a/support/dumpleak.myr b/support/dumpleak.myr index e5db06f..350298a 100644 --- a/support/dumpleak.myr +++ b/support/dumpleak.myr @@ -25,7 +25,7 @@ const main = {args ][:] ]) - for opt in cmd.opts + for opt : cmd.opts match opt | ('d', depth): match std.intparse(depth) @@ -39,7 +39,7 @@ const main = {args ;; stats.tab = std.mkht(std.inthash, std.inteq) - for d in cmd.args + for d : cmd.args match bio.open(d, bio.Rd) | `std.Ok f: dump(d, f, &stats) | `std.Err e: std.fatal("could not open {}: {}\n", d, e) @@ -100,7 +100,7 @@ const dumptrace = {tab var aggr aggr = std.mkht(hashintsl, std.sleq) - for (k, (sz, stk)) in std.byhtkeyvals(tab) + for (k, (sz, stk)) : std.byhtkeyvals(tab) match std.htget(aggr, stk[:stackaggr]) | `std.Some (count, total): std.htput(aggr, stk[:stackaggr], (count + 1, sz + total)) @@ -109,7 +109,7 @@ const dumptrace = {tab ;; ;; - for (stk, (n, sz)) in std.byhtkeyvals(aggr) + for (stk, (n, sz)) : std.byhtkeyvals(aggr) std.put("unfreed: {} (size: {}): {}\n", n, sz, stk) ;; } @@ -125,7 +125,7 @@ const hashintsl = {sl var h h = 0 - for i in sl + for i : sl h ^= std.inthash(i) ;; -> h diff --git a/test/arraypack.myr b/test/arraypack.myr index 51aa1bd..3866791 100644 --- a/test/arraypack.myr +++ b/test/arraypack.myr @@ -8,7 +8,7 @@ const a = [ ] const main = { - for x in a[:] + for x : a[:] std.put("{}", x) ;; std.put("\n") diff --git a/test/constslice.myr b/test/constslice.myr index 588f3ca..d8ec8fb 100644 --- a/test/constslice.myr +++ b/test/constslice.myr @@ -7,15 +7,15 @@ const array = [1,2,3,4,5] const main = { /* expected output 23 */ - for x in slpart + for x : slpart std.put("{}", x) ;; /* expected output 12345 */ - for x in slfull + for x : slfull std.put("{}", x) ;; /* expected output 678 */ - for x in slinline + for x : slinline std.put("{}", x) ;; std.put("\n") diff --git a/test/custiter.myr b/test/custiter.myr index 53238cd..ef44051 100644 --- a/test/custiter.myr +++ b/test/custiter.myr @@ -25,7 +25,7 @@ const main = { var x : int r = [.lo=6, .hi=11] - for v in r + for v : r x = v std.put("{}", x) ;; diff --git a/test/empty-struct.myr b/test/empty-struct.myr index a3ec75a..557522a 100644 --- a/test/empty-struct.myr +++ b/test/empty-struct.myr @@ -14,11 +14,11 @@ const main = { var z : foo[0] var b : bar = [.baz = [a, a][:], .quux = [z, z, z][:]] var c : int = 0 - for f in b.baz + for f : b.baz c += 3 ;; - for f in b.quux + for f : b.quux c += 5 ;; diff --git a/test/encodechar.myr b/test/encodechar.myr index 9cc3385..f7da629 100644 --- a/test/encodechar.myr +++ b/test/encodechar.myr @@ -11,7 +11,7 @@ const chartypes = { var buf : byte[32] s = "1世界äa\n" - for c in std.bychar(s) + for c : std.bychar(s) foo = c if std.encode(buf[:std.charlen(c)], c) == 0 std.write(1, "couldn't encode\n") diff --git a/test/patiter.myr b/test/patiter.myr index aee5883..9557e16 100644 --- a/test/patiter.myr +++ b/test/patiter.myr @@ -2,11 +2,11 @@ use std const main = { /* should print 1,3,5, skipping 4 */ - for (1,x) in [(1,2),(1,3),(2,4),(1,5)] + for (1,x) : [(1,2),(1,3),(2,4),(1,5)] std.put("{}", x) ;; /* should print 1, 2 skipping `None */ - for `std.Some v in [`std.None, `std.Some 1, `std.Some 2] + for `std.Some v : [`std.None, `std.Some 1, `std.Some 2] std.put("{}", v) ;; std.put("\n") diff --git a/test/subrangefor.myr b/test/subrangefor.myr index 7d397dd..6a8384f 100644 --- a/test/subrangefor.myr +++ b/test/subrangefor.myr @@ -1,7 +1,7 @@ use std const main = { - for i in [1,2,3,4][:2] + for i : [1,2,3,4][:2] std.put("{}", i) ;; std.put("\n") diff --git a/test/uconinit.myr b/test/uconinit.myr index 768df31..cd7e4a2 100644 --- a/test/uconinit.myr +++ b/test/uconinit.myr @@ -9,7 +9,7 @@ type u = union const a = [`A, `B, `C 123] const main = { - for v in a + for v : a match v | `A: std.put("A ") | `B: std.put("B ") |