From 2f9d121cdd4b0d236affca099eeb37698f5e222a Mon Sep 17 00:00:00 2001 From: Noah Gardner Date: Mon, 16 Nov 2026 10:59:46 -0500 Subject: [PATCH 1/2] build: ez 1.16.0, bolt 1.65.0 Co-Authored-By: Claude Opus 5.5 --- ez.lock.toml | 6 +++--- ez.toml | 6 +++--- flake.lock | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ez.lock.toml b/ez.lock.toml index d7ec2c3..6b24bba 100644 --- a/ez.lock.toml +++ b/ez.lock.toml @@ -4,8 +4,8 @@ hub = "https://hub.bend-lang.com" [tools] [tools.bolt] git = "https://github.com/Emerging-Patterns/bolt" -rev = "9700daf3a447089a8795d311912014382a74a2a9" -tag = "v1.27.0" +rev = "dfb06d0e5d6362739231b90bb090535af493b8f0" +tag = "v1.65.0" root = "." -narHash = "sha256-0S48j2dongVcvP5Oms5a+s5I12sIy91KAgwW0bP7pxM=" +narHash = "sha256-39sCydxFW7dWmf69CTJOXuC+j884fEhHWFKctdWCkAg=" entry = "main.bend" diff --git a/ez.toml b/ez.toml index 69010a7..18a730b 100644 --- a/ez.toml +++ b/ez.toml @@ -4,8 +4,8 @@ entry = "main.bend" [tools] [tools.bolt] git = "https://github.com/Emerging-Patterns/bolt" -rev = "9700daf3a447089a8795d311912014382a74a2a9" -tag = "v1.27.0" +rev = "dfb06d0e5d6362739231b90bb090535af493b8f0" +tag = "v1.65.0" root = "." -narHash = "sha256-0S48j2dongVcvP5Oms5a+s5I12sIy91KAgwW0bP7pxM=" +narHash = "sha256-39sCydxFW7dWmf69CTJOXuC+j884fEhHWFKctdWCkAg=" entry = "main.bend" diff --git a/flake.lock b/flake.lock index bd0339c..1e44901 100644 --- a/flake.lock +++ b/flake.lock @@ -31,11 +31,11 @@ ] }, "locked": { - "lastModified": 1794163393, - "narHash": "sha256-RwsUSTKjNvU7qGYKdaFItKGjtI/dy3cEjdDhZuN49tE=", + "lastModified": 1794759086, + "narHash": "sha256-DgFFeqCgFFWGXV+gFMOpvDKHLaVEiI73mxJQud7GUTU=", "owner": "Emerging-Patterns", "repo": "ez", - "rev": "35ace28d9578d8809a55d16941b0633e8fa774f5", + "rev": "c9f485554a0e11e40ee559d27875b052c22cdf65", "type": "github" }, "original": { From 79fbb1e94f85ae071070bcaa048ab2ab1861c9a3 Mon Sep 17 00:00:00 2001 From: Noah Gardner Date: Mon, 16 Nov 2026 11:04:29 -0500 Subject: [PATCH 2/2] fix(lint): bundle the parser walker's state into one Here record bolt 1.65's S009 (more than 8 parameters) fired on 28 parser steps in src/cli.bend, which all threaded the walker's eight fields (args, up, subs, path, binds, pos, raw, seen) one by one. They now take one `Here` value (the walker but its mode), with `parse.at` to rebuild the St and small `here.*` accessors. St itself is unchanged, so parsing behaves as before. The laws and proofs that named these internals (LongArgStep, PlainWordIsNeverOption, src/grow.bend, src/walk.bend, proofs/) are restated over the same calls with the fields bundled; no guarantee changed. Rules fixed: S009 x28. Co-Authored-By: Claude Opus 5.5 --- laws/LongArgStep.bend | 4 +- laws/PlainWordIsNeverOption.bend | 4 +- proofs/BindingsComeFromWords.bend | 390 +++++++++++-------- proofs/ChoiceRefused.bend | 6 +- proofs/EnterMissing.bend | 13 +- proofs/EnterStep.bend | 13 +- proofs/FlagLongValued.bend | 8 +- proofs/HelpUnknown.bend | 2 +- proofs/HelpWordAsksForHelp.bend | 8 +- proofs/LetterFlagAgain.bend | 12 +- proofs/LetterFlagEq.bend | 6 +- proofs/LetterOptAgain.bend | 12 +- proofs/LetterUnknown.bend | 2 +- proofs/LetterValue.bend | 27 +- proofs/LetterValueEq.bend | 39 +- proofs/LongBinds.bend | 15 +- proofs/LongNoName.bend | 12 +- proofs/LongRefused.bend | 20 +- proofs/PlainWordIsNeverOption.bend | 11 +- proofs/PositionalsBindInOrder.bend | 2 +- proofs/RawRefused.bend | 6 +- proofs/RepeatedLongFlag.bend | 15 +- proofs/RepeatedLongOpt.bend | 13 +- proofs/ShortClusterReadsLetters.bend | 26 +- proofs/ValueBinds.bend | 4 +- proofs/ValueFlagShaped.bend | 2 +- proofs/ValueRefused.bend | 4 +- proofs/lemmas/ClusterEnd.bend | 47 +-- proofs/lemmas/ClusterSteps.bend | 26 +- proofs/lemmas/HelpPathWalk.bend | 7 +- proofs/lemmas/WalkSteps.bend | 72 ++-- src/cli.bend | 560 +++++++-------------------- src/grow.bend | 81 ++-- src/walk.bend | 12 +- 34 files changed, 666 insertions(+), 815 deletions(-) diff --git a/laws/LongArgStep.bend b/laws/LongArgStep.bend index 87cc7a0..a09c669 100644 --- a/laws/LongArgStep.bend +++ b/laws/LongArgStep.bend @@ -18,5 +18,5 @@ law long_arg_step: for h_cut: {S.cut_eq(body) == (name, val) : String & Maybe<&2, String>} for h_name: {String.is_empty(name) == False{} : Bool} {S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen}) - == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, args, up, subs, path, bs, pos, - False{}, seen) : S.St} + == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St} diff --git a/laws/PlainWordIsNeverOption.bend b/laws/PlainWordIsNeverOption.bend index 5580faf..603315d 100644 --- a/laws/PlainWordIsNeverOption.bend +++ b/laws/PlainWordIsNeverOption.bend @@ -21,7 +21,7 @@ law plain_word_step: for +h_dash: {String.starts_with(tok, "-") == False{} : Bool} for h_help: {Bool.and(String.eq(tok, "help"), Bool.not(seen)) == False{} : Bool} {S.parse.step(tok, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen}) - == S.parse.word.go(S.find_sub(subs, tok), tok, args, up, subs, path, bs, pos, False{}, seen) : S.St} + == S.parse.word.go(S.find_sub(subs, tok), tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St} # LAW: in a free walker before `--`, the word `-` is read as a subcommand or a # positional, never as an option @@ -34,4 +34,4 @@ law dash_word_step: for +pos: List<&2, S.Arg> for +seen: Bool {S.parse.step("-", S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen}) - == S.parse.word.go(S.find_sub(subs, "-"), "-", args, up, subs, path, bs, pos, False{}, seen) : S.St} + == S.parse.word.go(S.find_sub(subs, "-"), "-", S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St} diff --git a/proofs/BindingsComeFromWords.bend b/proofs/BindingsComeFromWords.bend index 75da525..9cedd2b 100644 --- a/proofs/BindingsComeFromWords.bend +++ b/proofs/BindingsComeFromWords.bend @@ -301,7 +301,7 @@ def gv.put( +hv: {gv.ok(ws, val) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.put(name, val, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.put(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): gv.and_tt(Bool.and(gv.ok(ws, val), gv.all(binds, ws)), gv.ups(up, ws), gv.and_tt(gv.ok(ws, val), gv.all(binds, ws), hv, hb), hu) @@ -322,7 +322,7 @@ def gv.choice( +hv: {gv.ok(ws, val) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_choice(ok, name, val, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_choice(ok, name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match ok: case True{}: gv.put(name, val, args, up, subs, path, binds, pos, raw, seen, ws, hv, hb, hu) @@ -345,7 +345,7 @@ def gv.opt_val( +hv: {gv.ok(ws, val) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_opt_val(name, val, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_opt_val(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): gv.choice(S.allowed(S.parse.choices(S.by_name(args, name)), val), name, val, args, up, subs, path, binds, pos, raw, seen, ws, hv, hb, hu) @@ -365,7 +365,7 @@ def gv.flag( +ws: List<&2, String>, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_flag(val, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match val: case None{}: gv.put(name, "true", args, up, subs, path, binds, pos, raw, seen, ws, {==}, hb, hu) @@ -388,7 +388,7 @@ def gv.opt( +hm: {gv.mok(val, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_opt(val, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match val: case None{}: gv.keep(binds, up, ws, hb, hu) @@ -430,13 +430,14 @@ def gv.akind( +hm: {gv.mok(val, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_arg.kind(kk, name, val, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_arg.kind(kk, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match kk: case S.Flag{}: - gv.once(S.bound(binds, name), S.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), + gv.once(S.bound(binds, name), + S.parse.take_flag(val, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, ws, gv.flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen, ws, hb, hu)) case S.Opt{}: - gv.once(S.bound(binds, name), S.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), + gv.once(S.bound(binds, name), S.parse.take_opt(val, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, ws, gv.opt(val, name, args, up, subs, path, binds, pos, raw, seen, ws, hm, hb, hu)) case S.Many{}: gv.opt(val, name, args, up, subs, path, binds, pos, raw, seen, ws, hm, hb, hu) @@ -462,7 +463,7 @@ def gv.arg( +hm: {gv.mok(val, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_arg(found, val, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_arg(found, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match found: case None{}: gv.keep(binds, up, ws, hb, hu) @@ -486,7 +487,7 @@ def gv.lhelp( +ws: List<&2, String>, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_long.help(hit, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_long.help(hit, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match hit: case True{}: gv.keep(binds, up, ws, hb, hu) @@ -511,7 +512,7 @@ def gv.found( +hm: {gv.mok(val, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_long.found(found, name, val, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_long.found(found, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match found: case None{}: gv.lhelp(S.long_help(name, val, seen), orig, args, up, subs, path, binds, pos, raw, seen, ws, hb, hu) @@ -536,7 +537,7 @@ def gv.named( +hm: {gv.mok(val, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_long.named(empty, name, val, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_long.named(empty, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match empty: case True{}: gv.keep(binds, up, ws, hb, hu) @@ -559,7 +560,7 @@ def gv.cut( +hp: {gv.pok(nv, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_long.cut(nv, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_long.cut(nv, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match nv: case (+name, +val): gv.named(String.is_empty(name), name, val, orig, args, up, subs, path, binds, pos, raw, seen, ws, hp, hb, hu) @@ -619,7 +620,7 @@ def gv.long( hh: gv.In(body, ws), hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_long(body, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_long(body, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): ee = Equal.sym(String, String.from_list(String.to_list(body)), body, gv.round(body)) hr = {%ee : gv.In(_, ws) hh : gv.In(String.from_list(String.to_list(body)), ws)} @@ -707,7 +708,7 @@ def gv.capply_mode( +hh: {gv.sufs(rest, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.cluster.apply.mode(mode, cc, rest, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.cluster.apply.mode(mode, cc, rest, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match mode: case S.Dead{_e}: gv.keep(binds, up, ws, hb, hu) @@ -788,7 +789,7 @@ def gv.sgo( +hh: {gv.sufs(body, ws) == True{} : Bool}, +hb: {gv.all(binds, ws) == True{} : Bool}, +hu: {gv.ups(up, ws) == True{} : Bool} -) -> gv.G(S.parse.take_short.go(hit, body, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_short.go(hit, body, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match hit: case True{}: gv.keep(binds, up, ws, hb, hu) @@ -812,7 +813,7 @@ def gv.short( +hh: {gv.sufs(body, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.take_short(body, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.take_short(body, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): gv.sgo(S.short_help(body, args, seen), body, orig, args, up, subs, path, binds, pos, raw, seen, ws, hh, hb, hu) # a positional binds the word @@ -870,7 +871,7 @@ def gv.enter_or( +ws: List<&2, String>, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.enter_or(miss, ss, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.enter_or(miss, ss, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match miss: case None{}: gv.enter(ss, args, up, path, binds, ws, hb, hu) @@ -893,7 +894,7 @@ def gv.word_go( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.word.go(found, tok, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.word.go(found, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match found: case None{}: gv.take_pos(tok, args, up, subs, path, binds, pos, raw, ws, hh, hb, hu) @@ -915,7 +916,7 @@ def gv.word( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.word(tok, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.word(tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): gv.word_go(S.find_sub(subs, tok), tok, args, up, subs, path, binds, pos, raw, seen, ws, hh, hb, hu) # `-` alone is a word; otherwise a cluster @@ -933,7 +934,7 @@ def gv.short_go( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.step.short.go(alone, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gv.G(S.parse.step.short.go(alone, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): match alone: case True{}: gv.word(tok, args, up, subs, path, binds, pos, False{}, seen, ws, hh, hb, hu) @@ -956,7 +957,7 @@ def gv.step_short( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.step.short(dash, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gv.G(S.parse.step.short(dash, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): match dash: case True{}: gv.short_go(String.is_empty(String.drop(tok, 1n)), tok, args, up, subs, path, binds, pos, seen, ws, hh, hb, hu) @@ -979,7 +980,7 @@ def gv.kind_go( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.step.kind.go(long, dash, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gv.G(S.parse.step.kind.go(long, dash, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): match long: case True{}: gv.long(String.drop(tok, 2n), tok, args, up, subs, path, binds, pos, False{}, seen, ws, @@ -1001,7 +1002,7 @@ def gv.skind( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.step.kind(tok, args, up, subs, path, binds, pos, seen), ws): +) -> gv.G(S.parse.step.kind(tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): gv.kind_go(String.starts_with(tok, "--"), String.starts_with(tok, "-"), tok, args, up, subs, path, binds, pos, seen, ws, hh, hb, hu) @@ -1021,7 +1022,7 @@ def gv.help( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.step.help(hit, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gv.G(S.parse.step.help(hit, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): match hit: case True{}: gv.keep(binds, up, ws, hb, hu) @@ -1043,7 +1044,7 @@ def gv.end( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.step.end(end, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gv.G(S.parse.step.end(end, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): match end: case True{}: gv.keep(binds, up, ws, hb, hu) @@ -1066,7 +1067,7 @@ def gv.raw( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.step.raw(raw, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gv.G(S.parse.step.raw(tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match raw: case True{}: gv.take_pos(tok, args, up, subs, path, binds, pos, True{}, ws, hh, hb, hu) @@ -1090,7 +1091,7 @@ def gv.need( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.step.need(flag, name, tok, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.step.need(flag, name, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match flag: case True{}: gv.keep(binds, up, ws, hb, hu) @@ -1113,7 +1114,7 @@ def gv.help_path( _hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.step.help_path(found, tok, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.step.help_path(found, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match found: case None{}: gv.keep(binds, up, ws, hb, hu) @@ -1138,7 +1139,7 @@ def gv.mode( +hh: {gv.sufs(tok, ws) == True{} : Bool}, hb: gv.B(binds, ws), hu: gv.U(up, ws) -) -> gv.G(S.parse.step.mode(mode, tok, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gv.G(S.parse.step.mode(mode, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match mode: case S.Dead{_e}: gv.keep(binds, up, ws, hb, hu) @@ -1642,7 +1643,7 @@ def gn.put( +hv: {gv.ok(ws, val) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.put(name, val, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.put(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): gv.and_tt(gn.pin(pos, args), Bool.and(gn.nok(args, ws, S.Bind{name, val}), gn.all(binds, args, ws)), hp, gv.and_tt(gn.nok(args, ws, S.Bind{name, val}), gn.all(binds, args, ws), gv.and_tt(Laws.has_arg(args, name), gv.ok(ws, val), hn, hv), hb)) @@ -1665,7 +1666,7 @@ def gn.choice( +hv: {gv.ok(ws, val) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_choice(ok, name, val, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_choice(ok, name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match ok: case True{}: gn.put(name, val, args, up, subs, path, binds, pos, raw, seen, ws, hn, hv, hb, hp) @@ -1689,7 +1690,7 @@ def gn.opt_val( +hv: {gv.ok(ws, val) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_opt_val(name, val, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_opt_val(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): gn.choice(S.allowed(S.parse.choices(S.by_name(args, name)), val), name, val, args, up, subs, path, binds, pos, raw, seen, ws, hn, hv, hb, hp) @@ -1710,7 +1711,7 @@ def gn.flag( +hn: {Laws.has_arg(args, name) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_flag(val, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match val: case None{}: gn.put(name, "true", args, up, subs, path, binds, pos, raw, seen, ws, hn, {==}, hb, hp) @@ -1734,7 +1735,7 @@ def gn.opt( +hm: {gv.mok(val, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_opt(val, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match val: case None{}: gv.and_tt(Bool.and(Laws.has_arg(args, name), gn.pin(pos, args)), gn.all(binds, args, ws), @@ -1781,13 +1782,14 @@ def gn.akind( +hm: {gv.mok(val, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_arg.kind(kk, name, val, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_arg.kind(kk, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match kk: case S.Flag{}: - gn.once(S.bound(binds, name), S.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), + gn.once(S.bound(binds, name), + S.parse.take_flag(val, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, ws, gn.flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen, ws, hn, hb, hp)) case S.Opt{}: - gn.once(S.bound(binds, name), S.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), + gn.once(S.bound(binds, name), S.parse.take_opt(val, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, ws, gn.opt(val, name, args, up, subs, path, binds, pos, raw, seen, ws, hn, hm, hb, hp)) case S.Many{}: gn.opt(val, name, args, up, subs, path, binds, pos, raw, seen, ws, hn, hm, hb, hp) @@ -1814,7 +1816,7 @@ def gn.arg( +hm: {gv.mok(val, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_arg(found, val, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_arg(found, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match found: case None{}: gn.keep(args, binds, pos, ws, hb, hp) @@ -1838,7 +1840,7 @@ def gn.lhelp( +ws: List<&2, String>, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_long.help(hit, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_long.help(hit, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match hit: case True{}: gn.keep(args, binds, pos, ws, hb, hp) @@ -1864,7 +1866,7 @@ def gn.found( +hm: {gv.mok(val, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_long.found(found, name, val, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_long.found(found, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match found: case None{}: gn.lhelp(S.long_help(name, val, seen), orig, args, up, subs, path, binds, pos, raw, seen, ws, hb, hp) @@ -1889,7 +1891,7 @@ def gn.named( +hm: {gv.mok(val, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_long.named(empty, name, val, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_long.named(empty, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match empty: case True{}: gn.keep(args, binds, pos, ws, hb, hp) @@ -1913,7 +1915,7 @@ def gn.cut( +hq: {gv.pok(nv, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_long.cut(nv, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_long.cut(nv, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match nv: case (+name, +val): gn.named(String.is_empty(name), name, val, orig, args, up, subs, path, binds, pos, raw, seen, ws, hq, hb, hp) @@ -1934,7 +1936,7 @@ def gn.long( +hh: {gv.sufs(body, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_long(body, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_long(body, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): ee = Equal.sym(String, String.from_list(String.to_list(body)), body, gv.round(body)) hr = {%ee : gv.In(_, ws) hh : gv.In(String.from_list(String.to_list(body)), ws)} @@ -1959,7 +1961,7 @@ def gn.capply_mode( +hh: {gv.sufs(rest, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.cluster.apply.mode(mode, cc, rest, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.cluster.apply.mode(mode, cc, rest, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match mode: case S.Dead{_e}: gn.keep(args, binds, pos, ws, hb, hp) @@ -2045,7 +2047,7 @@ def gn.sgo( +hh: {gv.sufs(body, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_short.go(hit, body, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_short.go(hit, body, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match hit: case True{}: gn.keep(args, binds, pos, ws, hb, hp) @@ -2069,7 +2071,7 @@ def gn.short( +hh: {gv.sufs(body, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.take_short(body, orig, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.take_short(body, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): gn.sgo(S.short_help(body, args, seen), body, orig, args, up, subs, path, binds, pos, raw, seen, ws, hh, hb, hp) # a positional consumed, or kept when it is a rest @@ -2144,7 +2146,7 @@ def gn.enter_or( +ws: List<&2, String>, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.enter_or(miss, ss, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.enter_or(miss, ss, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match miss: case None{}: gn.enter(ss, args, up, path, binds, ws) @@ -2167,7 +2169,7 @@ def gn.word_go( +hh: {gv.sufs(tok, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.word.go(found, tok, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.word.go(found, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match found: case None{}: gn.take_pos(tok, args, up, subs, path, binds, pos, raw, ws, hh, hb, hp) @@ -2189,7 +2191,7 @@ def gn.word( +hh: {gv.sufs(tok, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.word(tok, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.word(tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): gn.word_go(S.find_sub(subs, tok), tok, args, up, subs, path, binds, pos, raw, seen, ws, hh, hb, hp) # `-` alone is a word; otherwise a cluster @@ -2207,7 +2209,7 @@ def gn.short_go( +hh: {gv.sufs(tok, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.step.short.go(alone, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gn.G(S.parse.step.short.go(alone, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): match alone: case True{}: gn.word(tok, args, up, subs, path, binds, pos, False{}, seen, ws, hh, hb, hp) @@ -2230,7 +2232,7 @@ def gn.step_short( +hh: {gv.sufs(tok, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.step.short(dash, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gn.G(S.parse.step.short(dash, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): match dash: case True{}: gn.short_go(String.is_empty(String.drop(tok, 1n)), tok, args, up, subs, path, binds, pos, seen, ws, hh, hb, hp) @@ -2253,7 +2255,7 @@ def gn.kind_go( +hh: {gv.sufs(tok, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.step.kind.go(long, dash, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gn.G(S.parse.step.kind.go(long, dash, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): match long: case True{}: gn.long(String.drop(tok, 2n), tok, args, up, subs, path, binds, pos, False{}, seen, ws, @@ -2275,7 +2277,7 @@ def gn.skind( +hh: {gv.sufs(tok, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.step.kind(tok, args, up, subs, path, binds, pos, seen), ws): +) -> gn.G(S.parse.step.kind(tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): gn.kind_go(String.starts_with(tok, "--"), String.starts_with(tok, "-"), tok, args, up, subs, path, binds, pos, seen, ws, hh, hb, hp) @@ -2295,7 +2297,7 @@ def gn.help( +hh: {gv.sufs(tok, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.step.help(hit, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gn.G(S.parse.step.help(hit, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): match hit: case True{}: gn.keep(args, binds, pos, ws, hb, hp) @@ -2317,7 +2319,7 @@ def gn.end( +hh: {gv.sufs(tok, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.step.end(end, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gn.G(S.parse.step.end(end, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), ws): match end: case True{}: gn.keep(args, binds, pos, ws, hb, hp) @@ -2340,7 +2342,7 @@ def gn.raw( +hh: {gv.sufs(tok, ws) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.step.raw(raw, tok, args, up, subs, path, binds, pos, seen), ws): +) -> gn.G(S.parse.step.raw(tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match raw: case True{}: gn.take_pos(tok, args, up, subs, path, binds, pos, True{}, ws, hh, hb, hp) @@ -2365,7 +2367,7 @@ def gn.need( +hn: {Laws.has_arg(args, name) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.step.need(flag, name, tok, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.step.need(flag, name, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match flag: case True{}: gn.keep(args, binds, pos, ws, hb, hp) @@ -2387,7 +2389,7 @@ def gn.help_path( +ws: List<&2, String>, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.step.help_path(found, tok, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.step.help_path(found, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match found: case None{}: gn.keep(args, binds, pos, ws, hb, hp) @@ -2413,7 +2415,7 @@ def gn.mode( +hm: {gn.min(mode, args) == True{} : Bool}, +hb: {gn.all(binds, args, ws) == True{} : Bool}, +hp: {gn.pin(pos, args) == True{} : Bool} -) -> gn.G(S.parse.step.mode(mode, tok, args, up, subs, path, binds, pos, raw, seen), ws): +) -> gn.G(S.parse.step.mode(mode, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), ws): match mode: case S.Dead{_e}: gn.keep(args, binds, pos, ws, hb, hp) @@ -2871,7 +2873,7 @@ def nd.put( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.put(name, val, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.put(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): nd.put_le(String.eq(val, "true"), Laws.valued(binds)) # a value bound when allowed @@ -2887,7 +2889,8 @@ def nd.choice( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_choice(ok, name, val, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_choice(ok, name, val, + S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match ok: case True{}: nd.put(name, val, args, up, subs, path, binds, pos, raw, seen) @@ -2906,7 +2909,7 @@ def nd.opt_val( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_opt_val(name, val, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_opt_val(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): nd.choice(S.allowed(S.parse.choices(S.by_name(args, name)), val), name, val, args, up, subs, path, binds, pos, raw, seen) @@ -2923,7 +2926,8 @@ def nd.flag( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_flag(val, name, orig, + S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match val: case None{}: nd.put(name, "true", args, up, subs, path, binds, pos, raw, seen) @@ -2942,7 +2946,7 @@ def nd.opt( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_opt(val, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match val: case None{}: nd.le_s(Laws.valued(binds)) @@ -2963,14 +2967,15 @@ def nd.akind( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_arg.kind(kk, name, val, orig, args, up, subs, path, binds, pos, raw, - seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_arg.kind(kk, name, val, orig, + S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match kk: case S.Flag{}: - nd.once(S.bound(binds, name), S.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), + nd.once(S.bound(binds, name), + S.parse.take_flag(val, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, 1n+Laws.valued(binds), nd.flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen)) case S.Opt{}: - nd.once(S.bound(binds, name), S.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), + nd.once(S.bound(binds, name), S.parse.take_opt(val, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, 1n+Laws.valued(binds), nd.opt(val, name, args, up, subs, path, binds, pos, raw, seen)) case S.Many{}: nd.opt(val, name, args, up, subs, path, binds, pos, raw, seen) @@ -2992,7 +2997,8 @@ def nd.arg( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_arg(found, val, orig, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_arg(found, val, orig, + S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match found: case None{}: nd.le_s(Laws.valued(binds)) @@ -3013,7 +3019,8 @@ def nd.lhelp( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_long.help(hit, orig, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_long.help(hit, orig, + S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match hit: case True{}: nd.le_s(Laws.valued(binds)) @@ -3034,7 +3041,7 @@ def nd.found( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_long.found(found, name, val, orig, args, up, subs, path, binds, pos, raw, seen), +) -> nd.T(S.parse.take_long.found(found, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match found: case None{}: @@ -3056,8 +3063,8 @@ def nd.named( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_long.named(empty, name, val, orig, args, up, subs, path, binds, pos, raw, - seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_long.named(empty, name, val, orig, + S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match empty: case True{}: nd.le_s(Laws.valued(binds)) @@ -3076,7 +3083,7 @@ def nd.cut( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_long.cut(nv, orig, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_long.cut(nv, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match nv: case (+name, +val): nd.named(String.is_empty(name), name, val, orig, args, up, subs, path, binds, pos, raw, seen) @@ -3093,7 +3100,7 @@ def nd.long( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_long(body, orig, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_long(body, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): nd.cut(S.cut_eq(body), orig, args, up, subs, path, binds, pos, raw, seen) # the bound on a cluster so far: the count it started with while no letter @@ -3144,17 +3151,18 @@ def nd.lflag( +seen: Bool, +n0: Nat, +hh: {Laws.nat_le(Laws.valued(binds), n0) == True{} : Bool} -) -> {nd.inv(S.parse.once(S.bound(binds, name), S.parse.take_flag(S.cluster.val.flag(eq, rest), name, orig, args, up, - subs, path, binds, pos, raw, seen), name, path), n0, eq) == True{} : Bool}: +) -> {nd.inv(S.parse.once(S.bound(binds, name), + S.parse.take_flag(S.cluster.val.flag(eq, rest), name, orig, + S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path), n0, eq) == True{} : Bool}: match eq: case True{}: - +st = S.parse.take_flag(Some{rest}, name, orig, args, up, subs, path, binds, pos, raw, seen) + +st = S.parse.take_flag(Some{rest}, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}) ee = Equal.sym(List<&2, S.Bind>, Laws.binds_of(S.parse.once(S.bound(binds, name), st, name, path)), Laws.binds_of(st), nd.once_keep(S.bound(binds, name), st, name, path)) %ee : {Laws.nat_le(Laws.valued(_), 1n+n0) == True{} : Bool} nd.le_trans(Laws.valued(binds), n0, 1n+n0, hh, nd.le_s(n0)) case False{}: - +st = S.parse.take_flag(None{}, name, orig, args, up, subs, path, binds, pos, raw, seen) + +st = S.parse.take_flag(None{}, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}) ee = Equal.sym(List<&2, S.Bind>, Laws.binds_of(S.parse.once(S.bound(binds, name), st, name, path)), Laws.binds_of(st), nd.once_keep(S.bound(binds, name), st, name, path)) %ee : {Laws.nat_le(Laws.valued(_), n0) == True{} : Bool} @@ -3175,7 +3183,8 @@ def nd.lpair( +seen: Bool, +n0: Nat, +hh: {Laws.nat_le(Laws.valued(binds), n0) == True{} : Bool} -) -> {nd.inv(S.parse.take_arg(found, S.cluster.val(found, rest), orig, args, up, subs, path, binds, pos, raw, seen), n0, +) -> {nd.inv(S.parse.take_arg(found, S.cluster.val(found, rest), orig, + S.Here{args, up, subs, path, binds, pos, raw, seen}), n0, S.cluster.ends(found, rest)) == True{} : Bool}: match found: case None{}: @@ -3189,14 +3198,14 @@ def nd.lpair( hh) case S.Opt{}: +vv = S.short_of.val(String.starts_with(rest, "="), rest) - nd.lift(S.parse.once(S.bound(binds, name), S.parse.take_opt(vv, name, args, up, subs, path, binds, pos, - raw, - seen), name, path), binds, n0, - nd.once(S.bound(binds, name), S.parse.take_opt(vv, name, args, up, subs, path, binds, pos, raw, seen), + nd.lift(S.parse.once(S.bound(binds, name), + S.parse.take_opt(vv, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path), binds, n0, + nd.once(S.bound(binds, name), + S.parse.take_opt(vv, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, 1n+Laws.valued(binds), nd.opt(vv, name, args, up, subs, path, binds, pos, raw, seen)), hh) case S.Many{}: +vv = S.short_of.val(String.starts_with(rest, "="), rest) - nd.lift(S.parse.take_opt(vv, name, args, up, subs, path, binds, pos, raw, seen), binds, n0, + nd.lift(S.parse.take_opt(vv, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), binds, n0, nd.opt(vv, name, args, up, subs, path, binds, pos, raw, seen), hh) case S.Pos{}: nd.le_trans(Laws.valued(binds), n0, 1n+n0, hh, nd.le_s(n0)) @@ -3232,7 +3241,7 @@ def nd.cmode( +seen: Bool, +n0: Nat, +hh: {Laws.nat_le(Laws.valued(binds), n0) == True{} : Bool} -) -> {nd.inv(S.cluster.apply.mode(mode, cc, rest, orig, args, up, subs, path, binds, pos, raw, seen), n0, +) -> {nd.inv(S.cluster.apply.mode(mode, cc, rest, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), n0, S.cluster.ends(S.by_short(args, SCon{cc, SNil{}}), rest)) == True{} : Bool}: match mode: case S.Dead{+ee}: @@ -3303,7 +3312,8 @@ def nd.sgo( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_short.go(hit, body, orig, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_short.go(hit, body, orig, + S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match hit: case True{}: nd.le_s(Laws.valued(binds)) @@ -3323,7 +3333,7 @@ def nd.short( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.take_short(body, orig, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.take_short(body, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): nd.sgo(S.short_help(body, args, seen), body, orig, args, up, subs, path, binds, pos, raw, seen) # a positional @@ -3371,7 +3381,7 @@ def nd.enter_or( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.enter_or(miss, ss, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.enter_or(miss, ss, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match miss: case None{}: nd.enter(ss, args, up, path, binds) @@ -3390,7 +3400,7 @@ def nd.word_go( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.word.go(found, tok, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.word.go(found, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match found: case None{}: nd.take_pos(tok, args, up, subs, path, binds, pos, raw) @@ -3408,7 +3418,7 @@ def nd.word( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.word(tok, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.word(tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): nd.word_go(S.find_sub(subs, tok), tok, args, up, subs, path, binds, pos, raw, seen) # `-` alone, or a cluster @@ -3422,7 +3432,8 @@ def nd.short_go( +binds: List<&2, S.Bind>, +pos: List<&2, S.Arg>, +seen: Bool -) -> nd.T(S.parse.step.short.go(alone, tok, args, up, subs, path, binds, pos, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.step.short.go(alone, tok, + S.Here{args, up, subs, path, binds, pos, False{}, seen}), 1n+Laws.valued(binds)): match alone: case True{}: nd.word(tok, args, up, subs, path, binds, pos, False{}, seen) @@ -3440,7 +3451,8 @@ def nd.step_short( +binds: List<&2, S.Bind>, +pos: List<&2, S.Arg>, +seen: Bool -) -> nd.T(S.parse.step.short(dash, tok, args, up, subs, path, binds, pos, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.step.short(dash, tok, + S.Here{args, up, subs, path, binds, pos, False{}, seen}), 1n+Laws.valued(binds)): match dash: case True{}: nd.short_go(String.is_empty(String.drop(tok, 1n)), tok, args, up, subs, path, binds, pos, seen) @@ -3459,7 +3471,8 @@ def nd.kind_go( +binds: List<&2, S.Bind>, +pos: List<&2, S.Arg>, +seen: Bool -) -> nd.T(S.parse.step.kind.go(long, dash, tok, args, up, subs, path, binds, pos, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.step.kind.go(long, dash, tok, + S.Here{args, up, subs, path, binds, pos, False{}, seen}), 1n+Laws.valued(binds)): match long: case True{}: nd.long(String.drop(tok, 2n), tok, args, up, subs, path, binds, pos, False{}, seen) @@ -3476,7 +3489,7 @@ def nd.skind( +binds: List<&2, S.Bind>, +pos: List<&2, S.Arg>, +seen: Bool -) -> nd.T(S.parse.step.kind(tok, args, up, subs, path, binds, pos, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.step.kind(tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), 1n+Laws.valued(binds)): nd.kind_go(String.starts_with(tok, "--"), String.starts_with(tok, "-"), tok, args, up, subs, path, binds, pos, seen) # `help` @@ -3490,7 +3503,7 @@ def nd.help( +binds: List<&2, S.Bind>, +pos: List<&2, S.Arg>, +seen: Bool -) -> nd.T(S.parse.step.help(hit, tok, args, up, subs, path, binds, pos, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.step.help(hit, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), 1n+Laws.valued(binds)): match hit: case True{}: nd.le_s(Laws.valued(binds)) @@ -3508,7 +3521,7 @@ def nd.end( +binds: List<&2, S.Bind>, +pos: List<&2, S.Arg>, +seen: Bool -) -> nd.T(S.parse.step.end(end, tok, args, up, subs, path, binds, pos, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.step.end(end, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), 1n+Laws.valued(binds)): match end: case True{}: nd.le_s(Laws.valued(binds)) @@ -3526,7 +3539,7 @@ def nd.raw( +binds: List<&2, S.Bind>, +pos: List<&2, S.Arg>, +seen: Bool -) -> nd.T(S.parse.step.raw(raw, tok, args, up, subs, path, binds, pos, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.step.raw(tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match raw: case True{}: nd.take_pos(tok, args, up, subs, path, binds, pos, True{}) @@ -3546,7 +3559,8 @@ def nd.need( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.step.need(flag, name, tok, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.step.need(flag, name, tok, + S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match flag: case True{}: nd.le_s(Laws.valued(binds)) @@ -3565,7 +3579,8 @@ def nd.help_path( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.step.help_path(found, tok, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.step.help_path(found, tok, + S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match found: case None{}: nd.le_s(Laws.valued(binds)) @@ -3586,7 +3601,7 @@ def nd.mode( +pos: List<&2, S.Arg>, +raw: Bool, +seen: Bool -) -> nd.T(S.parse.step.mode(mode, tok, args, up, subs, path, binds, pos, raw, seen), 1n+Laws.valued(binds)): +) -> nd.T(S.parse.step.mode(mode, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), 1n+Laws.valued(binds)): match mode: case S.Dead{_e}: nd.le_s(Laws.valued(binds)) @@ -3739,9 +3754,11 @@ def nu.put( +raw: Bool, +seen: Bool, +m0: S.Mode -) -> nu.N(S.parse.put(name, val, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, path, binds, +) -> nu.N(S.parse.put(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, subs, path, + binds, pos, raw, seen}): - nu.more(S.parse.put(name, val, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, path, binds, + nu.more(S.parse.put(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, List.length(&2, S.Bind, binds), {==}, {==}) @@ -3760,13 +3777,15 @@ def nu.choice( +seen: Bool, +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_choice(ok, name, val, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, +) -> nu.N(S.parse.take_choice(ok, name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, + subs, path, binds, pos, raw, seen}): match ok: case True{}: nu.put(name, val, args, up, subs, path, binds, pos, raw, seen, m0) case False{}: - nu.apart(S.parse.take_choice(False{}, name, val, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, + nu.apart(S.parse.take_choice(False{}, name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.dead(ss), {==}, hd) # an option's value @@ -3783,7 +3802,8 @@ def nu.opt_val( +seen: Bool, +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_opt_val(name, val, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, path, +) -> nu.N(S.parse.take_opt_val(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, + subs, path, binds, pos, raw, seen}): nu.choice(S.allowed(S.parse.choices(S.by_name(args, name)), val), name, val, args, up, subs, path, binds, pos, raw, seen, @@ -3804,13 +3824,15 @@ def nu.flag( +seen: Bool, +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, +) -> nu.N(S.parse.take_flag(val, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, + subs, path, binds, pos, raw, seen}): match val: case None{}: nu.put(name, "true", args, up, subs, path, binds, pos, raw, seen, m0) case Some{+vv}: - nu.apart(S.parse.take_flag(Some{vv}, name, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, + nu.apart(S.parse.take_flag(Some{vv}, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.dead(ss), {==}, hd) # an option @@ -3828,11 +3850,13 @@ def nu.opt( +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, path, +) -> nu.N(S.parse.take_opt(val, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, subs, + path, binds, pos, raw, seen}): match val: case None{}: - nu.apart(S.parse.take_opt(None{}, name, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, + nu.apart(S.parse.take_opt(None{}, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.need(ss), {==}, hn) case Some{vv}: @@ -3881,24 +3905,28 @@ def nu.akind( +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_arg.kind(kk, name, val, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, +) -> nu.N(S.parse.take_arg.kind(kk, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, + args, up, subs, path, binds, pos, raw, seen}): match kk: case S.Flag{}: - nu.once(S.bound(binds, name), S.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), + nu.once(S.bound(binds, name), + S.parse.take_flag(val, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, S.St{m0, args, up, subs, path, binds, pos, raw, seen}, hd, nu.flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen, m0, hd)) case S.Opt{}: - nu.once(S.bound(binds, name), S.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), + nu.once(S.bound(binds, name), S.parse.take_opt(val, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, S.St{m0, args, up, subs, path, binds, pos, raw, seen}, hd, nu.opt(val, name, args, up, subs, path, binds, pos, raw, seen, m0, hd, hn)) case S.Many{}: nu.opt(val, name, args, up, subs, path, binds, pos, raw, seen, m0, hd, hn) case S.Pos{}: - nu.apart(S.parse.take_arg.kind(S.Pos{}, name, val, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, + nu.apart(S.parse.take_arg.kind(S.Pos{}, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.dead(ss), {==}, hd) case S.Rest{}: - nu.apart(S.parse.take_arg.kind(S.Rest{}, name, val, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, + nu.apart(S.parse.take_arg.kind(S.Rest{}, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.dead(ss), {==}, hd) # a found argument, or an unknown flag @@ -3917,11 +3945,13 @@ def nu.arg( +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_arg(found, val, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, +) -> nu.N(S.parse.take_arg(found, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, + subs, path, binds, pos, raw, seen}): match found: case None{}: - nu.apart(S.parse.take_arg(None{}, val, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, + nu.apart(S.parse.take_arg(None{}, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.dead(ss), {==}, hd) case Some{aa}: match aa: @@ -3943,14 +3973,17 @@ def nu.lhelp( +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_long.help(hit, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, +) -> nu.N(S.parse.take_long.help(hit, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, + subs, path, binds, pos, raw, seen}): match hit: case True{}: - nu.apart(S.parse.take_long.help(True{}, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, + nu.apart(S.parse.take_long.help(True{}, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.help(ss), {==}, hl) case False{}: - nu.apart(S.parse.take_long.help(False{}, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, + nu.apart(S.parse.take_long.help(False{}, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.dead(ss), {==}, hd) # a long option the current command spells, or an unknown one @@ -3971,7 +4004,7 @@ def nu.found( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_long.found(found, name, val, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, +) -> nu.N(S.parse.take_long.found(found, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, subs, path, binds, pos, raw, seen}): match found: case None{}: @@ -3997,11 +4030,13 @@ def nu.named( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_long.named(empty, name, val, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, +) -> nu.N(S.parse.take_long.named(empty, name, val, orig, + S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, subs, path, binds, pos, raw, seen}): match empty: case True{}: - nu.apart(S.parse.take_long.named(True{}, name, val, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, + nu.apart(S.parse.take_long.named(True{}, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.dead(ss), {==}, hd) case False{}: nu.found(S.by_long(args, name), name, val, orig, args, up, subs, path, binds, pos, raw, seen, m0, hd, hn, hl) @@ -4022,7 +4057,8 @@ def nu.cut( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_long.cut(nv, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, path, +) -> nu.N(S.parse.take_long.cut(nv, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, + subs, path, binds, pos, raw, seen}): match nv: case (+name, +val): @@ -4045,7 +4081,8 @@ def nu.long( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_long(body, orig, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, path, +) -> nu.N(S.parse.take_long(body, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, subs, + path, binds, pos, raw, seen}): nu.cut(S.cut_eq(body), orig, args, up, subs, path, binds, pos, raw, seen, m0, hd, hn, hl) @@ -4080,7 +4117,7 @@ def nu.jput( +seen: Bool, +l0: Nat, +hl0: {Laws.nat_le(l0, List.length(&2, S.Bind, binds)) == True{} : Bool} -) -> {nu.J(S.parse.put(name, val, args, up, subs, path, binds, pos, raw, seen), l0) == True{} : Bool}: +) -> {nu.J(S.parse.put(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), l0) == True{} : Bool}: gv.and_tt(Laws.nat_le(l0, 1n+List.length(&2, S.Bind, binds)), Laws.nat_le(l0, List.length(&2, S.Bind, binds)), nd.le_trans(l0, List.length(&2, S.Bind, binds), 1n+List.length(&2, S.Bind, binds), hl0, nd.le_s(List.length(&2, S.Bind, binds))), hl0) @@ -4100,12 +4137,14 @@ def nu.jchoice( +seen: Bool, +l0: Nat, +hl0: {Laws.nat_le(l0, List.length(&2, S.Bind, binds)) == True{} : Bool} -) -> {nu.J(S.parse.take_choice(ok, name, val, args, up, subs, path, binds, pos, raw, seen), l0) == True{} : Bool}: +) -> {nu.J(S.parse.take_choice(ok, name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), + l0) == True{} : Bool}: match ok: case True{}: nu.jput(name, val, args, up, subs, path, binds, pos, raw, seen, l0, hl0) case False{}: - nu.j_stop(S.parse.take_choice(False{}, name, val, args, up, subs, path, binds, pos, raw, seen), l0, hl0, {==}) + nu.j_stop(S.parse.take_choice(False{}, name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), l0, hl0, + {==}) # an option's value def nu.jopt_val( @@ -4121,7 +4160,7 @@ def nu.jopt_val( +seen: Bool, +l0: Nat, +hl0: {Laws.nat_le(l0, List.length(&2, S.Bind, binds)) == True{} : Bool} -) -> {nu.J(S.parse.take_opt_val(name, val, args, up, subs, path, binds, pos, raw, seen), l0) == True{} : Bool}: +) -> {nu.J(S.parse.take_opt_val(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), l0) == True{} : Bool}: nu.jchoice(S.allowed(S.parse.choices(S.by_name(args, name)), val), name, val, args, up, subs, path, binds, pos, raw, seen, l0, hl0) @@ -4140,12 +4179,14 @@ def nu.jflag( +seen: Bool, +l0: Nat, +hl0: {Laws.nat_le(l0, List.length(&2, S.Bind, binds)) == True{} : Bool} -) -> {nu.J(S.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), l0) == True{} : Bool}: +) -> {nu.J(S.parse.take_flag(val, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + l0) == True{} : Bool}: match val: case None{}: nu.jput(name, "true", args, up, subs, path, binds, pos, raw, seen, l0, hl0) case Some{+vv}: - nu.j_stop(S.parse.take_flag(Some{vv}, name, orig, args, up, subs, path, binds, pos, raw, seen), l0, hl0, {==}) + nu.j_stop(S.parse.take_flag(Some{vv}, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), l0, hl0, + {==}) # an option def nu.jopt( @@ -4161,10 +4202,10 @@ def nu.jopt( +seen: Bool, +l0: Nat, +hl0: {Laws.nat_le(l0, List.length(&2, S.Bind, binds)) == True{} : Bool} -) -> {nu.J(S.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), l0) == True{} : Bool}: +) -> {nu.J(S.parse.take_opt(val, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), l0) == True{} : Bool}: match val: case None{}: - nu.j_stop(S.parse.take_opt(None{}, name, args, up, subs, path, binds, pos, raw, seen), l0, hl0, {==}) + nu.j_stop(S.parse.take_opt(None{}, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), l0, hl0, {==}) case Some{vv}: nu.jopt_val(name, vv, args, up, subs, path, binds, pos, raw, seen, l0, hl0) @@ -4204,22 +4245,25 @@ def nu.jakind( +seen: Bool, +l0: Nat, +hl0: {Laws.nat_le(l0, List.length(&2, S.Bind, binds)) == True{} : Bool} -) -> {nu.J(S.parse.take_arg.kind(kk, name, val, orig, args, up, subs, path, binds, pos, raw, seen), +) -> {nu.J(S.parse.take_arg.kind(kk, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), l0) == True{} : Bool}: match kk: case S.Flag{}: - nu.jonce(S.bound(binds, name), S.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), + nu.jonce(S.bound(binds, name), + S.parse.take_flag(val, name, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, l0, nu.jflag(val, name, orig, args, up, subs, path, binds, pos, raw, seen, l0, hl0)) case S.Opt{}: - nu.jonce(S.bound(binds, name), S.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), + nu.jonce(S.bound(binds, name), S.parse.take_opt(val, name, S.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, l0, nu.jopt(val, name, args, up, subs, path, binds, pos, raw, seen, l0, hl0)) case S.Many{}: nu.jopt(val, name, args, up, subs, path, binds, pos, raw, seen, l0, hl0) case S.Pos{}: - nu.j_stop(S.parse.take_arg.kind(S.Pos{}, name, val, orig, args, up, subs, path, binds, pos, raw, seen), l0, hl0, + nu.j_stop(S.parse.take_arg.kind(S.Pos{}, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + l0, hl0, {==}) case S.Rest{}: - nu.j_stop(S.parse.take_arg.kind(S.Rest{}, name, val, orig, args, up, subs, path, binds, pos, raw, seen), l0, + nu.j_stop(S.parse.take_arg.kind(S.Rest{}, name, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + l0, hl0, {==}) # a found argument, or an unknown flag @@ -4237,10 +4281,11 @@ def nu.jarg( +seen: Bool, +l0: Nat, +hl0: {Laws.nat_le(l0, List.length(&2, S.Bind, binds)) == True{} : Bool} -) -> {nu.J(S.parse.take_arg(found, val, orig, args, up, subs, path, binds, pos, raw, seen), l0) == True{} : Bool}: +) -> {nu.J(S.parse.take_arg(found, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), + l0) == True{} : Bool}: match found: case None{}: - nu.j_stop(S.parse.take_arg(None{}, val, orig, args, up, subs, path, binds, pos, raw, seen), l0, hl0, {==}) + nu.j_stop(S.parse.take_arg(None{}, val, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), l0, hl0, {==}) case Some{aa}: match aa: case S.Arg{+name, _s, _l, kind, _h, _r, _d, _c}: @@ -4262,7 +4307,7 @@ def nu.jmode( +seen: Bool, +l0: Nat, +hl0: {Laws.nat_le(l0, List.length(&2, S.Bind, binds)) == True{} : Bool} -) -> {nu.J(S.cluster.apply.mode(mode, cc, rest, orig, args, up, subs, path, binds, pos, raw, seen), +) -> {nu.J(S.cluster.apply.mode(mode, cc, rest, orig, S.Here{args, up, subs, path, binds, pos, raw, seen}), l0) == True{} : Bool}: match mode: case S.Dead{+ee}: @@ -4395,11 +4440,12 @@ def nu.sgo( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.take_short.go(hit, SCon{cc, rest}, orig, args, up, subs, path, binds, pos, False{}, seen), +) -> nu.N(S.parse.take_short.go(hit, SCon{cc, rest}, orig, S.Here{args, up, subs, path, binds, pos, False{}, seen}), S.St{m0, args, up, subs, path, binds, pos, False{}, seen}): match hit: case True{}: - nu.apart(S.parse.take_short.go(True{}, SCon{cc, rest}, orig, args, up, subs, path, binds, pos, False{}, seen), + nu.apart(S.parse.take_short.go(True{}, SCon{cc, rest}, orig, + S.Here{args, up, subs, path, binds, pos, False{}, seen}), S.St{m0, args, up, subs, path, binds, pos, False{}, seen}, ss => nu.help(ss), {==}, hl) case False{}: nu.cluster1(cc, rest, orig, args, up, subs, path, binds, pos, seen, m0, hd, hn, hl) @@ -4420,11 +4466,11 @@ def nu.cl0( +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool}, +he: {String.is_empty(body) == False{} : Bool} -) -> nu.N(S.parse.take_short(body, orig, args, up, subs, path, binds, pos, False{}, seen), +) -> nu.N(S.parse.take_short(body, orig, S.Here{args, up, subs, path, binds, pos, False{}, seen}), S.St{m0, args, up, subs, path, binds, pos, False{}, seen}): match body: case SNil{}: - Empty.absurd(nu.N(S.parse.take_short(SNil{}, orig, args, up, subs, path, binds, pos, False{}, seen), + Empty.absurd(nu.N(S.parse.take_short(SNil{}, orig, S.Here{args, up, subs, path, binds, pos, False{}, seen}), S.St{m0, args, up, subs, path, binds, pos, False{}, seen}), Walk.wk.true_false(he)) case SCon{+cc, +rest}: nu.sgo(S.short_help(SCon{cc, rest}, args, seen), cc, rest, orig, args, up, subs, path, binds, pos, seen, m0, hd, @@ -4447,13 +4493,14 @@ def nu.choice_any( +orig: S.St, +hb: {nu.blen(orig) == List.length(&2, S.Bind, binds) : Nat}, +hd: {nu.dead(orig) == False{} : Bool} -) -> nu.N(S.parse.take_choice(ok, name, val, args, up, subs, path, binds, pos, raw, seen), orig): +) -> nu.N(S.parse.take_choice(ok, name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), orig): match ok: case True{}: - nu.more(S.parse.put(name, val, args, up, subs, path, binds, pos, raw, seen), orig, List.length(&2, S.Bind, binds), + nu.more(S.parse.put(name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), orig, + List.length(&2, S.Bind, binds), {==}, hb) case False{}: - nu.apart(S.parse.take_choice(False{}, name, val, args, up, subs, path, binds, pos, raw, seen), orig, + nu.apart(S.parse.take_choice(False{}, name, val, S.Here{args, up, subs, path, binds, pos, raw, seen}), orig, ss => nu.dead(ss), {==}, hd) # a positional binds the word, or none is left @@ -4518,13 +4565,15 @@ def nu.enter_or( +seen: Bool, +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool} -) -> nu.N(S.parse.enter_or(miss, ss, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, path, +) -> nu.N(S.parse.enter_or(miss, ss, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, subs, + path, binds, pos, raw, seen}): match miss: case None{}: nu.enter(ss, args, up, subs, path, binds, pos, raw, seen, m0) case Some{+nn}: - nu.apart(S.parse.enter_or(Some{nn}, ss, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, + nu.apart(S.parse.enter_or(Some{nn}, ss, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.dead(ss), {==}, hd) # a word @@ -4541,7 +4590,8 @@ def nu.word_go( +seen: Bool, +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool} -) -> nu.N(S.parse.word.go(found, tok, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, path, +) -> nu.N(S.parse.word.go(found, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, subs, + path, binds, pos, raw, seen}): match found: case None{}: @@ -4562,7 +4612,8 @@ def nu.word( +seen: Bool, +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool} -) -> nu.N(S.parse.word(tok, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, path, binds, pos, +) -> nu.N(S.parse.word(tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, subs, path, binds, + pos, raw, seen}): nu.word_go(S.find_sub(subs, tok), tok, args, up, subs, path, binds, pos, raw, seen, m0, hd) @@ -4582,7 +4633,8 @@ def nu.short_go( +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool}, +ha: {String.is_empty(String.drop(tok, 1n)) == alone : Bool} -) -> nu.N(S.parse.step.short.go(alone, tok, args, up, subs, path, binds, pos, seen), S.St{m0, args, up, subs, path, +) -> nu.N(S.parse.step.short.go(alone, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), S.St{m0, args, + up, subs, path, binds, pos, False{}, seen}): match alone: case True{}: @@ -4605,7 +4657,8 @@ def nu.step_short( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.step.short(dash, tok, args, up, subs, path, binds, pos, seen), S.St{m0, args, up, subs, path, binds, +) -> nu.N(S.parse.step.short(dash, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), S.St{m0, args, up, + subs, path, binds, pos, False{}, seen}): match dash: case True{}: @@ -4630,7 +4683,8 @@ def nu.kind_go( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.step.kind.go(long, dash, tok, args, up, subs, path, binds, pos, seen), S.St{m0, args, up, subs, +) -> nu.N(S.parse.step.kind.go(long, dash, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), S.St{m0, + args, up, subs, path, binds, pos, False{}, seen}): match long: case True{}: @@ -4652,7 +4706,8 @@ def nu.skind( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.step.kind(tok, args, up, subs, path, binds, pos, seen), S.St{m0, args, up, subs, path, binds, pos, +) -> nu.N(S.parse.step.kind(tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), S.St{m0, args, up, subs, + path, binds, pos, False{}, seen}): nu.kind_go(String.starts_with(tok, "--"), String.starts_with(tok, "-"), tok, args, up, subs, path, binds, pos, seen, m0, @@ -4673,11 +4728,13 @@ def nu.help_w( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.step.help(hit, tok, args, up, subs, path, binds, pos, seen), S.St{m0, args, up, subs, path, binds, +) -> nu.N(S.parse.step.help(hit, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), S.St{m0, args, up, + subs, path, binds, pos, False{}, seen}): match hit: case True{}: - nu.apart(S.parse.step.help(True{}, tok, args, up, subs, path, binds, pos, seen), S.St{m0, args, up, subs, path, + nu.apart(S.parse.step.help(True{}, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), + S.St{m0, args, up, subs, path, binds, pos, False{}, seen}, ss => nu.help(ss), {==}, hl) case False{}: nu.skind(tok, args, up, subs, path, binds, pos, seen, m0, hd, hn, hl) @@ -4697,11 +4754,13 @@ def nu.end( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.step.end(end, tok, args, up, subs, path, binds, pos, seen), S.St{m0, args, up, subs, path, binds, +) -> nu.N(S.parse.step.end(end, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), S.St{m0, args, up, subs, + path, binds, pos, False{}, seen}): match end: case True{}: - nu.apart(S.parse.step.end(True{}, tok, args, up, subs, path, binds, pos, seen), S.St{m0, args, up, subs, path, + nu.apart(S.parse.step.end(True{}, tok, S.Here{args, up, subs, path, binds, pos, False{}, seen}), + S.St{m0, args, up, subs, path, binds, pos, False{}, seen}, ss => nu.raw(ss), {==}, {==}) case False{}: nu.help_w(Bool.and(String.eq(tok, "help"), Bool.not(seen)), tok, args, up, subs, path, binds, pos, seen, m0, hd, @@ -4723,7 +4782,8 @@ def nu.rawf( +hd: {nu.dead_m(m0) == False{} : Bool}, +hn: {nu.need_m(m0) == False{} : Bool}, +hl: {nu.help_m(m0) == False{} : Bool} -) -> nu.N(S.parse.step.raw(raw, tok, args, up, subs, path, binds, pos, seen), S.St{m0, args, up, subs, path, binds, +) -> nu.N(S.parse.step.raw(tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, subs, path, + binds, pos, raw, seen}): match raw: case True{}: @@ -4746,11 +4806,13 @@ def nu.need_w( +seen: Bool, +m0: S.Mode, +hd: {nu.dead_m(m0) == False{} : Bool} -) -> nu.N(S.parse.step.need(flag, name, tok, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, subs, +) -> nu.N(S.parse.step.need(flag, name, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), S.St{m0, args, up, + subs, path, binds, pos, raw, seen}): match flag: case True{}: - nu.apart(S.parse.step.need(True{}, name, tok, args, up, subs, path, binds, pos, raw, seen), S.St{m0, args, up, + nu.apart(S.parse.step.need(True{}, name, tok, S.Here{args, up, subs, path, binds, pos, raw, seen}), + S.St{m0, args, up, subs, path, binds, pos, raw, seen}, ss => nu.dead(ss), {==}, hd) case False{}: nu.opt_val(name, tok, args, up, subs, path, binds, pos, raw, seen, m0, hd) diff --git a/proofs/ChoiceRefused.bend b/proofs/ChoiceRefused.bend index c845861..4ef01d7 100644 --- a/proofs/ChoiceRefused.bend +++ b/proofs/ChoiceRefused.bend @@ -42,9 +42,9 @@ def choice_refused.step( h_sub)) %e1 : {D1.dead_of(_) == Some{S.BadValue{path, name, tok}} : Maybe<&2, S.ParseErr>} e2 = Equal.sym(Bool, S.allowed(cs, tok), False{}, h_bad) - %e2 : {D1.dead_of(S.parse.take_choice(_, name, tok, args, up, subs, path, bs, - S.parse.take_pos.keep(S.rest.is(S.Arg{name, sh, lo, kind, hp, req, dflt, cs}), - S.Arg{name, sh, lo, kind, hp, req, dflt, cs}, rest), False{}, True{})) + %e2 : {D1.dead_of(S.parse.take_choice(_, name, tok, + S.Here{args, up, subs, path, bs, S.parse.take_pos.keep(S.rest.is(S.Arg{name, sh, lo, kind, hp, req, dflt, cs}), + S.Arg{name, sh, lo, kind, hp, req, dflt, cs}, rest), False{}, True{}})) == Some{S.BadValue{path, name, tok}} : Maybe<&2, S.ParseErr>} {==} diff --git a/proofs/EnterMissing.bend b/proofs/EnterMissing.bend index 7245f81..a204608 100644 --- a/proofs/EnterMissing.bend +++ b/proofs/EnterMissing.bend @@ -19,10 +19,10 @@ def enter.miss( +bs: List<&2, S.Bind>, +seen: Bool, h_req: {S.parse.first_req(pos) == Some{nm} : Maybe<&2, String>} -) -> {D1.dead_of(S.parse.enter_or(S.parse.first_req(pos), sub, args, up, subs, path, bs, pos, False{}, seen)) +) -> {D1.dead_of(S.parse.enter_or(S.parse.first_req(pos), sub, S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.Missing{path, nm}} : Maybe<&2, S.ParseErr>}: er = Equal.sym(Maybe<&2, String>, S.parse.first_req(pos), Some{nm}, h_req) - %er : {D1.dead_of(S.parse.enter_or(_, sub, args, up, subs, path, bs, pos, False{}, seen)) + %er : {D1.dead_of(S.parse.enter_or(_, sub, S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.Missing{path, nm}} : Maybe<&2, S.ParseErr>} {==} @@ -61,12 +61,13 @@ def Laws.enter_missing( ): +st = {S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e1 = Equal.sym(S.St, S.parse.step(tok, st), - S.parse.enter_or(S.parse.first_req(pos), sub, args, up, subs, path, bs, pos, False{}, seen), + S.parse.enter_or(S.parse.first_req(pos), sub, S.Here{args, up, subs, path, bs, pos, False{}, seen}), Equal.trans(S.St, S.parse.step(tok, st), - S.parse.word.go(S.find_sub(subs, tok), tok, args, up, subs, path, bs, pos, False{}, seen), - S.parse.enter_or(S.parse.first_req(pos), sub, args, up, subs, path, bs, pos, False{}, seen), + S.parse.word.go(S.find_sub(subs, tok), tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}), + S.parse.enter_or(S.parse.first_req(pos), sub, S.Here{args, up, subs, path, bs, pos, False{}, seen}), M2.enter.word(tok, args, up, subs, path, bs, pos, seen, h_dd, h_help, h_dash), M2.enter.go(tok, args, up, subs, path, bs, pos, seen, sub, h_sub))) L1.refused(spec, pre, more, tok, st, S.Missing{path, nm}, h_at, - enter.dead(tok, st, S.parse.enter_or(S.parse.first_req(pos), sub, args, up, subs, path, bs, pos, False{}, seen), + enter.dead(tok, st, S.parse.enter_or(S.parse.first_req(pos), sub, + S.Here{args, up, subs, path, bs, pos, False{}, seen}), S.Missing{path, nm}, e1, enter.miss(pos, sub, nm, args, up, subs, path, bs, seen, h_req))) diff --git a/proofs/EnterStep.bend b/proofs/EnterStep.bend index e82139c..869b870 100644 --- a/proofs/EnterStep.bend +++ b/proofs/EnterStep.bend @@ -18,12 +18,12 @@ def enter.none( +bs: List<&2, S.Bind>, +seen: Bool, h_req: {S.parse.first_req(pos) == None{} : Maybe<&2, String>} -) -> {S.parse.enter_or(S.parse.first_req(pos), S.Sub{name, about, next, kids}, args, up, subs, path, bs, pos, False{}, - seen) +) -> {S.parse.enter_or(S.parse.first_req(pos), S.Sub{name, about, next, kids}, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Free{}, next, S.Level{args, bs} <> up, kids, List.append(&2, String, path, [name]), [], S.pos_of(next), False{}, False{}} : S.St}: er = Equal.sym(Maybe<&2, String>, S.parse.first_req(pos), None{}, h_req) - %er : {S.parse.enter_or(_, S.Sub{name, about, next, kids}, args, up, subs, path, bs, pos, False{}, seen) + %er : {S.parse.enter_or(_, S.Sub{name, about, next, kids}, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Free{}, next, S.Level{args, bs} <> up, kids, List.append(&2, String, path, [name]), [], S.pos_of(next), False{}, False{}} : S.St} {==} @@ -57,9 +57,10 @@ def Laws.enter_step( Equal.trans(S.St, S.parse.walk(List.append(&2, String, pre, [tok]), S.parse.start(spec)), S.parse.step(tok, st), rhs, M1.kept.stepped(spec, pre, tok, st, h_at), Equal.trans(S.St, S.parse.step(tok, st), - S.parse.word.go(S.find_sub(subs, tok), tok, args, up, subs, path, bs, pos, False{}, seen), rhs, + S.parse.word.go(S.find_sub(subs, tok), tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}), rhs, M1.enter.word(tok, args, up, subs, path, bs, pos, seen, h_dd, h_help, h_dash), - Equal.trans(S.St, S.parse.word.go(S.find_sub(subs, tok), tok, args, up, subs, path, bs, pos, False{}, seen), - S.parse.enter_or(S.parse.first_req(pos), sub, args, up, subs, path, bs, pos, False{}, seen), rhs, + Equal.trans(S.St, S.parse.word.go(S.find_sub(subs, tok), tok, + S.Here{args, up, subs, path, bs, pos, False{}, seen}), + S.parse.enter_or(S.parse.first_req(pos), sub, S.Here{args, up, subs, path, bs, pos, False{}, seen}), rhs, M1.enter.go(tok, args, up, subs, path, bs, pos, seen, sub, h_sub), enter.none(pos, name, about, next, kids, args, up, subs, path, bs, seen, h_req)))) diff --git a/proofs/FlagLongValued.bend b/proofs/FlagLongValued.bend index f5a01ae..ccbb337 100644 --- a/proofs/FlagLongValued.bend +++ b/proofs/FlagLongValued.bend @@ -35,13 +35,13 @@ def flag_long_valued.step( ) -> {D1.dead_of(S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen})) == Some{S.Unexpected{path, "--" ++ body}} : Maybe<&2, S.ParseErr>}: e1 = Equal.sym(S.St, S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen}), - S.parse.take_long.found(S.by_long(args, name), name, Some{vv}, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen), + S.parse.take_long.found(S.by_long(args, name), name, Some{vv}, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}), L1.long_arg_step(body, name, Some{vv}, args, up, subs, path, bs, pos, seen, h_dd, h_cut, h_name)) %e1 : {D1.dead_of(_) == Some{S.Unexpected{path, "--" ++ body}} : Maybe<&2, S.ParseErr>} e2 = Equal.sym(Maybe<&2, S.Arg>, S.by_long(args, name), Some{S.Arg{nn, sh, lo, S.Flag{}, hp, req, dflt, cs}}, h_found) - %e2 : {D1.dead_of(S.parse.take_long.found(_, name, Some{vv}, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen)) + %e2 : {D1.dead_of(S.parse.take_long.found(_, name, Some{vv}, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.Unexpected{path, "--" ++ body}} : Maybe<&2, S.ParseErr>} e3 = Equal.sym(Bool, S.bound(bs, nn), False{}, h_once) %e3 : {D1.dead_of(S.parse.once(_, S.St{S.Dead{S.Unexpected{path, "--" ++ body}}, args, up, subs, path, bs, pos, diff --git a/proofs/HelpUnknown.bend b/proofs/HelpUnknown.bend index 7338424..ec15a49 100644 --- a/proofs/HelpUnknown.bend +++ b/proofs/HelpUnknown.bend @@ -22,7 +22,7 @@ def help_unknown.step( ) -> {D1.dead_of(S.parse.step(tok, S.St{S.Help{}, args, up, subs, path, bs, pos, raw, seen})) == Some{S.Unexpected{path, tok}} : Maybe<&2, S.ParseErr>}: ee = Equal.sym(Maybe<&2, S.Sub>, S.find_sub(subs, tok), None{}, h_sub) - %ee : {D1.dead_of(S.parse.step.help_path(_, tok, args, up, subs, path, bs, pos, raw, seen)) + %ee : {D1.dead_of(S.parse.step.help_path(_, tok, S.Here{args, up, subs, path, bs, pos, raw, seen})) == Some{S.Unexpected{path, tok}} : Maybe<&2, S.ParseErr>} {==} diff --git a/proofs/HelpWordAsksForHelp.bend b/proofs/HelpWordAsksForHelp.bend index 60c38d4..b5386b2 100644 --- a/proofs/HelpWordAsksForHelp.bend +++ b/proofs/HelpWordAsksForHelp.bend @@ -57,7 +57,7 @@ def dash_help.step( ) -> {S.parse.step("--help", S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, False{}}) == S.St{S.Help{}, args, up, subs, path, bs, pos, False{}, False{}} : S.St}: ee = Equal.sym(Maybe<&2, S.Arg>, S.by_long(args, "help"), None{}, h_none) - %ee : {S.parse.take_long.found(_, "help", None{}, "--help", args, up, subs, path, bs, pos, False{}, False{}) + %ee : {S.parse.take_long.found(_, "help", None{}, "--help", S.Here{args, up, subs, path, bs, pos, False{}, False{}}) == S.St{S.Help{}, args, up, subs, path, bs, pos, False{}, False{}} : S.St} {==} @@ -89,12 +89,12 @@ def short_help.step( == S.St{S.Help{}, args, up, subs, path, bs, pos, False{}, False{}} : S.St}: e1 = Equal.sym(Maybe<&2, S.Arg>, S.by_short(args, "h"), None{}, h_short) %e1 : {S.parse.take_short.go(Bool.and(True{}, Bool.and(True{}, Bool.and(Maybe.is_none(&2, S.Arg, _), - Maybe.is_none(&2, S.Arg, S.by_long(args, "help"))))), "h", "-h", args, up, subs, path, bs, pos, False{}, - False{}) + Maybe.is_none(&2, S.Arg, + S.by_long(args, "help"))))), "h", "-h", S.Here{args, up, subs, path, bs, pos, False{}, False{}}) == S.St{S.Help{}, args, up, subs, path, bs, pos, False{}, False{}} : S.St} e2 = Equal.sym(Maybe<&2, S.Arg>, S.by_long(args, "help"), None{}, h_long) %e2 : {S.parse.take_short.go(Bool.and(True{}, Bool.and(True{}, Bool.and(True{}, Maybe.is_none(&2, S.Arg, _)))), - "h", "-h", args, up, subs, path, bs, pos, False{}, False{}) + "h", "-h", S.Here{args, up, subs, path, bs, pos, False{}, False{}}) == S.St{S.Help{}, args, up, subs, path, bs, pos, False{}, False{}} : S.St} {==} diff --git a/proofs/LetterFlagAgain.bend b/proofs/LetterFlagAgain.bend index 7f4e788..24bc61a 100644 --- a/proofs/LetterFlagAgain.bend +++ b/proofs/LetterFlagAgain.bend @@ -35,10 +35,10 @@ def Laws.letter_flag_again( e0 = M1.cl.back(cc, rest, orig, args, up, subs, path, bs, pos, raw, seen, aa, h_found) %e0 : {D1.dead_of(_) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} e2 = Equal.sym(Bool, S.bound(bs, nn), True{}, h_again) - %e2 : {D1.dead_of(S.cluster(rest, orig, S.parse.once(_, S.parse.take_flag(vv, nn, orig, args, up, subs, - path, bs, pos, - raw, seen), nn, path), String.starts_with(rest, "="))) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} - M2.cl.dead(rest, orig, S.parse.once(True{}, S.parse.take_flag(vv, nn, orig, args, up, subs, path, bs, pos, raw, - seen), nn, + %e2 : {D1.dead_of(S.cluster(rest, orig, + S.parse.once(_, S.parse.take_flag(vv, nn, orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), nn, + path), String.starts_with(rest, "="))) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} + M2.cl.dead(rest, orig, + S.parse.once(True{}, S.parse.take_flag(vv, nn, orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), nn, path), String.starts_with(rest, "="), S.Repeated{path, nn}, - L1.once_dead(S.parse.take_flag(vv, nn, orig, args, up, subs, path, bs, pos, raw, seen), nn, path)) + L1.once_dead(S.parse.take_flag(vv, nn, orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), nn, path)) diff --git a/proofs/LetterFlagEq.bend b/proofs/LetterFlagEq.bend index 44e3a5e..60031d0 100644 --- a/proofs/LetterFlagEq.bend +++ b/proofs/LetterFlagEq.bend @@ -34,9 +34,9 @@ def Laws.letter_flag_eq( e0 = M2.cl.back(cc, rest, orig, args, up, subs, path, bs, pos, raw, seen, aa, h_found) %e0 : {_ == dd : S.St} e1 = Equal.sym(Bool, String.starts_with(rest, "="), True{}, h_eq) - %e1 : {S.cluster(rest, orig, S.parse.take_arg.kind(S.Flag{}, nn, S.cluster.val.flag(_, rest), orig, args, up, - subs, path, - bs, pos, raw, seen), _) == dd : S.St} + %e1 : {S.cluster(rest, orig, + S.parse.take_arg.kind(S.Flag{}, nn, S.cluster.val.flag(_, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), _) == dd : S.St} e2 = Equal.sym(Bool, S.bound(bs, nn), False{}, h_once) %e2 : {S.cluster(rest, orig, S.parse.once(_, dd, nn, path), True{}) == dd : S.St} L1.cluster_done(rest, orig, dd) diff --git a/proofs/LetterOptAgain.bend b/proofs/LetterOptAgain.bend index 631ab14..98ec1bc 100644 --- a/proofs/LetterOptAgain.bend +++ b/proofs/LetterOptAgain.bend @@ -35,9 +35,11 @@ def Laws.letter_opt_again( e0 = M1.cl.back(cc, rest, orig, args, up, subs, path, bs, pos, raw, seen, aa, h_found) %e0 : {D1.dead_of(_) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} e2 = Equal.sym(Bool, S.bound(bs, nn), True{}, h_again) - %e2 : {D1.dead_of(S.cluster(rest, orig, S.parse.once(_, S.parse.take_opt(vv, nn, args, up, subs, path, bs, pos, raw, - seen), nn, path), True{})) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} - M2.cl.dead(rest, orig, S.parse.once(True{}, S.parse.take_opt(vv, nn, args, up, subs, path, bs, pos, raw, seen), + %e2 : {D1.dead_of(S.cluster(rest, orig, + S.parse.once(_, S.parse.take_opt(vv, nn, S.Here{args, up, subs, path, bs, pos, raw, seen}), nn, + path), True{})) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} + M2.cl.dead(rest, orig, + S.parse.once(True{}, S.parse.take_opt(vv, nn, S.Here{args, up, subs, path, bs, pos, raw, seen}), nn, path), - True{}, S.Repeated{path, nn}, L1.once_dead(S.parse.take_opt(vv, nn, args, up, subs, path, bs, pos, raw, - seen), nn, path)) + True{}, S.Repeated{path, + nn}, L1.once_dead(S.parse.take_opt(vv, nn, S.Here{args, up, subs, path, bs, pos, raw, seen}), nn, path)) diff --git a/proofs/LetterUnknown.bend b/proofs/LetterUnknown.bend index e2b99b4..ba8d3d0 100644 --- a/proofs/LetterUnknown.bend +++ b/proofs/LetterUnknown.bend @@ -9,6 +9,6 @@ def Laws.letter_unknown(cc, rest, orig, args, up, subs, path, bs, pos, raw, seen +dd = {S.St{S.Dead{S.UnknownFlag{path, orig}}, args, up, subs, path, bs, pos, raw, seen} : S.St} e2 = Equal.sym(Maybe<&2, S.Arg>, S.by_short(args, SCon{cc, SNil{}}), None{}, h_none) %e2 : {S.cluster(rest, orig, - S.parse.take_arg(_, S.cluster.val(_, rest), orig, args, up, subs, path, bs, pos, raw, seen), + S.parse.take_arg(_, S.cluster.val(_, rest), orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), S.cluster.ends(_, rest)) == dd : S.St} L1.cluster_done(rest, orig, dd) diff --git a/proofs/LetterValue.bend b/proofs/LetterValue.bend index 671ff61..c8a0761 100644 --- a/proofs/LetterValue.bend +++ b/proofs/LetterValue.bend @@ -23,8 +23,8 @@ def lv.ty( +seen: Bool, +nn: String ) -> Type: - {S.cluster(rest, orig, S.parse.take_arg.kind(kk, nn, S.cluster.val.kind(kk, rest), orig, args, up, subs, path, - bs, pos, raw, seen), + {S.cluster(rest, orig, + S.parse.take_arg.kind(kk, nn, S.cluster.val.kind(kk, rest), orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), S.cluster.ends.kind(kk, rest)) == S.St{S.Free{}, args, up, subs, path, S.Bind{nn, rest} <> bs, pos, raw, seen} : S.St} @@ -52,33 +52,36 @@ def lv( case S.Opt{}: +T = {S.St{S.Free{}, args, up, subs, path, S.Bind{nn, rest} <> bs, pos, raw, seen} : S.St} e1 = Equal.sym(Bool, String.starts_with(rest, "="), False{}, h_noeq) - %e1 : {S.cluster(rest, orig, S.parse.take_arg.kind(S.Opt{}, nn, S.short_of.val(_, rest), orig, args, up, - subs, path, bs, pos, raw, seen), True{}) + %e1 : {S.cluster(rest, orig, + S.parse.take_arg.kind(S.Opt{}, nn, S.short_of.val(_, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} e2 = Equal.sym(Bool, String.is_empty(rest), False{}, h_some) %e2 : {S.cluster(rest, orig, S.parse.take_arg.kind(S.Opt{}, nn, Bool.pick(Maybe<&2, String>, _, None{}, - Some{rest}), orig, args, up, subs, path, bs, pos, raw, seen), True{}) == T : S.St} + Some{rest}), orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} e3 = Equal.sym(Bool, S.bound(bs, nn), False{}, Walk.wk.not_true(S.bound(bs, nn), h_kind)) - %e3 : {S.cluster(rest, orig, S.parse.once(_, S.parse.take_opt(Some{rest}, nn, args, up, subs, path, bs, - pos, raw, seen), nn, path), True{}) == T + %e3 : {S.cluster(rest, orig, + S.parse.once(_, S.parse.take_opt(Some{rest}, nn, S.Here{args, up, subs, path, bs, pos, raw, seen}), nn, + path), True{}) == T : S.St} e4 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, nn)), rest), True{}, h_ok) - %e4 : {S.cluster(rest, orig, S.parse.take_choice(_, nn, rest, args, up, subs, path, bs, pos, raw, seen), + %e4 : {S.cluster(rest, orig, S.parse.take_choice(_, nn, rest, S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} L1.cluster_done(rest, orig, T) case S.Many{}: +T = {S.St{S.Free{}, args, up, subs, path, S.Bind{nn, rest} <> bs, pos, raw, seen} : S.St} e1 = Equal.sym(Bool, String.starts_with(rest, "="), False{}, h_noeq) - %e1 : {S.cluster(rest, orig, S.parse.take_arg.kind(S.Many{}, nn, S.short_of.val(_, rest), orig, args, up, - subs, path, bs, pos, raw, seen), True{}) + %e1 : {S.cluster(rest, orig, + S.parse.take_arg.kind(S.Many{}, nn, S.short_of.val(_, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} e2 = Equal.sym(Bool, String.is_empty(rest), False{}, h_some) %e2 : {S.cluster(rest, orig, S.parse.take_arg.kind(S.Many{}, nn, Bool.pick(Maybe<&2, String>, _, None{}, - Some{rest}), orig, args, up, subs, path, bs, pos, raw, seen), True{}) == T : S.St} + Some{rest}), orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} e4 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, nn)), rest), True{}, h_ok) - %e4 : {S.cluster(rest, orig, S.parse.take_choice(_, nn, rest, args, up, subs, path, bs, pos, raw, seen), + %e4 : {S.cluster(rest, orig, S.parse.take_choice(_, nn, rest, S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} L1.cluster_done(rest, orig, T) case S.Flag{}: diff --git a/proofs/LetterValueEq.bend b/proofs/LetterValueEq.bend index d56197d..b0705f9 100644 --- a/proofs/LetterValueEq.bend +++ b/proofs/LetterValueEq.bend @@ -26,8 +26,9 @@ def le.ty( +seen: Bool, +nn: String ) -> Type: - {S.cluster("=" ++ vv, orig, S.parse.take_arg.kind(kk, nn, S.cluster.val.kind(kk, "=" ++ vv), orig, args, up, - subs, path, bs, pos, raw, seen), + {S.cluster("=" ++ vv, orig, + S.parse.take_arg.kind(kk, nn, S.cluster.val.kind(kk, "=" ++ vv), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), S.cluster.ends.kind(kk, "=" ++ vv)) == S.St{S.Free{}, args, up, subs, path, S.Bind{nn, vv} <> bs, pos, raw, seen} : S.St} @@ -52,33 +53,37 @@ def le( case S.Opt{}: +T = {S.St{S.Free{}, args, up, subs, path, S.Bind{nn, vv} <> bs, pos, raw, seen} : S.St} ep = Equal.sym(Bool, String.starts_with(vv, ""), True{}, L3.prefix_empty(vv)) - %ep : {S.cluster("=" ++ vv, orig, S.parse.take_arg.kind(S.Opt{}, nn, S.short_of.val(_, "=" ++ vv), orig, args, up, - subs, path, bs, pos, raw, seen), True{}) == T : S.St} + %ep : {S.cluster("=" ++ vv, orig, + S.parse.take_arg.kind(S.Opt{}, nn, S.short_of.val(_, "=" ++ vv), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} ed = Equal.sym(String, String.drop(vv, 0n), vv, L2.drop_zero(vv)) - %ed : {S.cluster("=" ++ vv, orig, S.parse.take_arg.kind(S.Opt{}, nn, Some{_}, orig, args, up, subs, path, - bs, pos, raw, seen), True{}) == T + %ed : {S.cluster("=" ++ vv, orig, + S.parse.take_arg.kind(S.Opt{}, nn, Some{_}, orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} e3 = Equal.sym(Bool, S.bound(bs, nn), False{}, Walk.wk.not_true(S.bound(bs, nn), h_kind)) - %e3 : {S.cluster("=" ++ vv, orig, S.parse.once(_, S.parse.take_opt(Some{vv}, nn, args, up, subs, path, bs, - pos, raw, seen), nn, path), True{}) == T + %e3 : {S.cluster("=" ++ vv, orig, + S.parse.once(_, S.parse.take_opt(Some{vv}, nn, S.Here{args, up, subs, path, bs, pos, raw, seen}), nn, + path), True{}) == T : S.St} e4 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, nn)), vv), True{}, h_ok) - %e4 : {S.cluster("=" ++ vv, orig, S.parse.take_choice(_, nn, vv, args, up, subs, path, bs, pos, raw, - seen), True{}) == T : S.St} + %e4 : {S.cluster("=" ++ vv, orig, + S.parse.take_choice(_, nn, vv, S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} L1.cluster_done("=" ++ vv, orig, T) case S.Many{}: +T = {S.St{S.Free{}, args, up, subs, path, S.Bind{nn, vv} <> bs, pos, raw, seen} : S.St} ep = Equal.sym(Bool, String.starts_with(vv, ""), True{}, L3.prefix_empty(vv)) - %ep : {S.cluster("=" ++ vv, orig, S.parse.take_arg.kind(S.Many{}, nn, S.short_of.val(_, "=" ++ vv), orig, - args, up, - subs, path, bs, pos, raw, seen), True{}) == T : S.St} + %ep : {S.cluster("=" ++ vv, orig, + S.parse.take_arg.kind(S.Many{}, nn, S.short_of.val(_, "=" ++ vv), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} ed = Equal.sym(String, String.drop(vv, 0n), vv, L2.drop_zero(vv)) - %ed : {S.cluster("=" ++ vv, orig, S.parse.take_arg.kind(S.Many{}, nn, Some{_}, orig, args, up, subs, path, - bs, pos, raw, seen), True{}) == T + %ed : {S.cluster("=" ++ vv, orig, + S.parse.take_arg.kind(S.Many{}, nn, Some{_}, orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} e4 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, nn)), vv), True{}, h_ok) - %e4 : {S.cluster("=" ++ vv, orig, S.parse.take_choice(_, nn, vv, args, up, subs, path, bs, pos, raw, - seen), True{}) == T : S.St} + %e4 : {S.cluster("=" ++ vv, orig, + S.parse.take_choice(_, nn, vv, S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} L1.cluster_done("=" ++ vv, orig, T) case S.Flag{}: Empty.absurd(le.ty(S.Flag{}, vv, orig, args, up, subs, path, bs, pos, raw, seen, nn), Walk.wk.false_true(h_kind)) diff --git a/proofs/LongBinds.bend b/proofs/LongBinds.bend index d8a68f1..5dd73c5 100644 --- a/proofs/LongBinds.bend +++ b/proofs/LongBinds.bend @@ -24,7 +24,7 @@ def long.kind.ty( +pos: List<&2, S.Arg>, +seen: Bool ) -> Type: - {S.parse.take_arg.kind(kk, nn, Some{vv}, orig, args, up, subs, path, bs, pos, False{}, seen) + {S.parse.take_arg.kind(kk, nn, Some{vv}, orig, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Free{}, args, up, subs, path, S.Bind{nn, vv} <> bs, pos, False{}, seen} : S.St} # an option that takes a value now binds an allowed one @@ -46,15 +46,16 @@ def long.kind( match kk: case S.Opt{}: e1 = Equal.sym(Bool, S.bound(bs, nn), False{}, Walk.wk.not_true(S.bound(bs, nn), h_kind)) - %e1 : {S.parse.once(_, S.parse.take_opt(Some{vv}, nn, args, up, subs, path, bs, pos, False{}, seen), nn, path) + %e1 : {S.parse.once(_, S.parse.take_opt(Some{vv}, nn, S.Here{args, up, subs, path, bs, pos, False{}, seen}), nn, + path) == S.St{S.Free{}, args, up, subs, path, S.Bind{nn, vv} <> bs, pos, False{}, seen} : S.St} e2 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, nn)), vv), True{}, h_ok) - %e2 : {S.parse.take_choice(_, nn, vv, args, up, subs, path, bs, pos, False{}, seen) + %e2 : {S.parse.take_choice(_, nn, vv, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Free{}, args, up, subs, path, S.Bind{nn, vv} <> bs, pos, False{}, seen} : S.St} {==} case S.Many{}: e2 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, nn)), vv), True{}, h_ok) - %e2 : {S.parse.take_choice(_, nn, vv, args, up, subs, path, bs, pos, False{}, seen) + %e2 : {S.parse.take_choice(_, nn, vv, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Free{}, args, up, subs, path, S.Bind{nn, vv} <> bs, pos, False{}, seen} : S.St} {==} case S.Flag{}: @@ -96,12 +97,12 @@ def long.step( ) -> {S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Free{}, args, up, subs, path, S.Bind{nn, vv} <> bs, pos, False{}, seen} : S.St}: e1 = Equal.sym(S.St, S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen}), - S.parse.take_long.found(S.by_long(args, name), name, Some{vv}, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen), + S.parse.take_long.found(S.by_long(args, name), name, Some{vv}, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}), L2.long_arg_step(body, name, Some{vv}, args, up, subs, path, bs, pos, seen, h_dd, h_cut, h_name)) %e1 : {_ == S.St{S.Free{}, args, up, subs, path, S.Bind{nn, vv} <> bs, pos, False{}, seen} : S.St} e2 = Equal.sym(Maybe<&2, S.Arg>, S.by_long(args, name), Some{S.Arg{nn, sh, lo, kind, hp, req, dflt, cs}}, h_found) - %e2 : {S.parse.take_long.found(_, name, Some{vv}, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen) + %e2 : {S.parse.take_long.found(_, name, Some{vv}, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Free{}, args, up, subs, path, S.Bind{nn, vv} <> bs, pos, False{}, seen} : S.St} long.kind(kind, nn, vv, "--" ++ body, args, up, subs, path, bs, pos, seen, h_kind, h_ok) diff --git a/proofs/LongNoName.bend b/proofs/LongNoName.bend index 6f9a4a9..ff95a66 100644 --- a/proofs/LongNoName.bend +++ b/proofs/LongNoName.bend @@ -30,20 +30,20 @@ def long_no_name.step( ) -> {D1.dead_of(S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen})) == Some{S.UnknownFlag{path, "--" ++ body}} : Maybe<&2, S.ParseErr>}: e1 = Equal.sym(Bool, String.eq("--" ++ body, "--"), False{}, h_dd) - %e1 : {D1.dead_of(S.parse.step.end(_, "--" ++ body, args, up, subs, path, bs, pos, seen)) + %e1 : {D1.dead_of(S.parse.step.end(_, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.UnknownFlag{path, "--" ++ body}} : Maybe<&2, S.ParseErr>} e0 = Equal.sym(Bool, String.starts_with(body, ""), True{}, L2.prefix_empty(body)) - %e0 : {D1.dead_of(S.parse.step.kind.go(_, True{}, "--" ++ body, args, up, subs, path, bs, pos, seen)) + %e0 : {D1.dead_of(S.parse.step.kind.go(_, True{}, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.UnknownFlag{path, "--" ++ body}} : Maybe<&2, S.ParseErr>} ed = Equal.sym(String, String.drop(body, 0n), body, L1.drop_zero(body)) - %ed : {D1.dead_of(S.parse.take_long(_, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen)) + %ed : {D1.dead_of(S.parse.take_long(_, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.UnknownFlag{path, "--" ++ body}} : Maybe<&2, S.ParseErr>} e2 = Equal.sym(String & Maybe<&2, String>, S.cut_eq(body), (name, val), h_cut) - %e2 : {D1.dead_of(S.parse.take_long.cut(_, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen)) + %e2 : {D1.dead_of(S.parse.take_long.cut(_, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.UnknownFlag{path, "--" ++ body}} : Maybe<&2, S.ParseErr>} e3 = Equal.sym(Bool, String.is_empty(name), True{}, h_empty) - %e3 : {D1.dead_of(S.parse.take_long.named(_, name, val, "--" ++ body, args, up, subs, path, bs, pos, - False{}, seen)) + %e3 : {D1.dead_of(S.parse.take_long.named(_, name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.UnknownFlag{path, "--" ++ body}} : Maybe<&2, S.ParseErr>} {==} diff --git a/proofs/LongRefused.bend b/proofs/LongRefused.bend index ab4cbb6..afc99c8 100644 --- a/proofs/LongRefused.bend +++ b/proofs/LongRefused.bend @@ -24,7 +24,7 @@ def long_refused.kind.ty( +pos: List<&2, S.Arg>, +seen: Bool ) -> Type: - {D2.dead_of(S.parse.take_arg.kind(kk, nn, Some{vv}, orig, args, up, subs, path, bs, pos, False{}, seen)) + {D2.dead_of(S.parse.take_arg.kind(kk, nn, Some{vv}, orig, S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.BadValue{path, nn, vv}} : Maybe<&2, S.ParseErr>} # an option that takes a value now refuses one outside its choices @@ -46,15 +46,17 @@ def long_refused.kind( match kk: case S.Opt{}: e1 = Equal.sym(Bool, S.bound(bs, nn), False{}, Walk.wk.not_true(S.bound(bs, nn), h_kind)) - %e1 : {D2.dead_of(S.parse.once(_, S.parse.take_opt(Some{vv}, nn, args, up, subs, path, bs, pos, False{}, - seen), nn, path)) == Some{S.BadValue{path, nn, vv}} : Maybe<&2, S.ParseErr>} + %e1 : {D2.dead_of(S.parse.once(_, + S.parse.take_opt(Some{vv}, nn, + S.Here{args, up, subs, path, bs, pos, False{}, + seen}), nn, path)) == Some{S.BadValue{path, nn, vv}} : Maybe<&2, S.ParseErr>} e2 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, nn)), vv), False{}, h_bad) - %e2 : {D2.dead_of(S.parse.take_choice(_, nn, vv, args, up, subs, path, bs, pos, False{}, seen)) + %e2 : {D2.dead_of(S.parse.take_choice(_, nn, vv, S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.BadValue{path, nn, vv}} : Maybe<&2, S.ParseErr>} {==} case S.Many{}: e2 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, nn)), vv), False{}, h_bad) - %e2 : {D2.dead_of(S.parse.take_choice(_, nn, vv, args, up, subs, path, bs, pos, False{}, seen)) + %e2 : {D2.dead_of(S.parse.take_choice(_, nn, vv, S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.BadValue{path, nn, vv}} : Maybe<&2, S.ParseErr>} {==} case S.Flag{}: @@ -96,13 +98,13 @@ def long_refused.step( ) -> {D2.dead_of(S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen})) == Some{S.BadValue{path, nn, vv}} : Maybe<&2, S.ParseErr>}: e1 = Equal.sym(S.St, S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen}), - S.parse.take_long.found(S.by_long(args, name), name, Some{vv}, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen), + S.parse.take_long.found(S.by_long(args, name), name, Some{vv}, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}), L1.long_arg_step(body, name, Some{vv}, args, up, subs, path, bs, pos, seen, h_dd, h_cut, h_name)) %e1 : {D2.dead_of(_) == Some{S.BadValue{path, nn, vv}} : Maybe<&2, S.ParseErr>} e2 = Equal.sym(Maybe<&2, S.Arg>, S.by_long(args, name), Some{S.Arg{nn, sh, lo, kind, hp, req, dflt, cs}}, h_found) - %e2 : {D2.dead_of(S.parse.take_long.found(_, name, Some{vv}, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen)) + %e2 : {D2.dead_of(S.parse.take_long.found(_, name, Some{vv}, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.BadValue{path, nn, vv}} : Maybe<&2, S.ParseErr>} long_refused.kind(kind, nn, vv, "--" ++ body, args, up, subs, path, bs, pos, seen, h_kind, h_bad) diff --git a/proofs/PlainWordIsNeverOption.bend b/proofs/PlainWordIsNeverOption.bend index bffac36..4377811 100644 --- a/proofs/PlainWordIsNeverOption.bend +++ b/proofs/PlainWordIsNeverOption.bend @@ -5,15 +5,16 @@ import ../src/walk.bend as Walk import ../laws/PlainWordIsNeverOption.bend as Laws def Laws.plain_word_step(tok, args, up, subs, path, bs, pos, seen, h_dd, h_dash, h_help): - +rhs = S.parse.word.go(S.find_sub(subs, tok), tok, args, up, subs, path, bs, pos, False{}, seen) + +rhs = S.parse.word.go(S.find_sub(subs, tok), tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) e1 = Equal.sym(Bool, String.eq(tok, "--"), False{}, h_dd) - %e1 : {S.parse.step.end(_, tok, args, up, subs, path, bs, pos, seen) == rhs : S.St} + %e1 : {S.parse.step.end(_, tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == rhs : S.St} e2 = Equal.sym(Bool, Bool.and(String.eq(tok, "help"), Bool.not(seen)), False{}, h_help) - %e2 : {S.parse.step.help(_, tok, args, up, subs, path, bs, pos, seen) == rhs : S.St} + %e2 : {S.parse.step.help(_, tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == rhs : S.St} e3 = Equal.sym(Bool, String.starts_with(tok, "--"), False{}, Walk.wk.dash(tok, h_dash)) - %e3 : {S.parse.step.kind.go(_, String.starts_with(tok, "-"), tok, args, up, subs, path, bs, pos, seen) == rhs : S.St} + %e3 : {S.parse.step.kind.go(_, String.starts_with(tok, "-"), tok, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) == rhs : S.St} e4 = Equal.sym(Bool, String.starts_with(tok, "-"), False{}, h_dash) - %e4 : {S.parse.step.kind.go(False{}, _, tok, args, up, subs, path, bs, pos, seen) == rhs : S.St} + %e4 : {S.parse.step.kind.go(False{}, _, tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == rhs : S.St} {==} def Laws.dash_word_step(_args, _up, _subs, _path, _bs, _pos, _seen): diff --git a/proofs/PositionalsBindInOrder.bend b/proofs/PositionalsBindInOrder.bend index 2d9d077..6b074f0 100644 --- a/proofs/PositionalsBindInOrder.bend +++ b/proofs/PositionalsBindInOrder.bend @@ -59,7 +59,7 @@ def hw.step( ) -> {S.parse.step("help", S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, True{}}) == S.parse.take_pos("help", args, up, subs, path, bs, pos, False{}) : S.St}: ee = Equal.sym(Maybe<&2, S.Sub>, S.find_sub(subs, "help"), None{}, h_sub) - %ee : {S.parse.word.go(_, "help", args, up, subs, path, bs, pos, False{}, True{}) + %ee : {S.parse.word.go(_, "help", S.Here{args, up, subs, path, bs, pos, False{}, True{}}) == S.parse.take_pos("help", args, up, subs, path, bs, pos, False{}) : S.St} {==} diff --git a/proofs/RawRefused.bend b/proofs/RawRefused.bend index 593ac7c..c49157b 100644 --- a/proofs/RawRefused.bend +++ b/proofs/RawRefused.bend @@ -28,9 +28,9 @@ def raw_refused.step( ) -> {D1.dead_of(S.parse.step(tok, S.St{S.Free{}, args, up, subs, path, bs, S.Arg{name, sh, lo, kind, hp, req, dflt, cs} <> rest, True{}, seen})) == Some{S.BadValue{path, name, tok}} : Maybe<&2, S.ParseErr>}: e2 = Equal.sym(Bool, S.allowed(cs, tok), False{}, h_bad) - %e2 : {D1.dead_of(S.parse.take_choice(_, name, tok, args, up, subs, path, bs, - S.parse.take_pos.keep(S.rest.is(S.Arg{name, sh, lo, kind, hp, req, dflt, cs}), - S.Arg{name, sh, lo, kind, hp, req, dflt, cs}, rest), True{}, True{})) + %e2 : {D1.dead_of(S.parse.take_choice(_, name, tok, + S.Here{args, up, subs, path, bs, S.parse.take_pos.keep(S.rest.is(S.Arg{name, sh, lo, kind, hp, req, dflt, cs}), + S.Arg{name, sh, lo, kind, hp, req, dflt, cs}, rest), True{}, True{}})) == Some{S.BadValue{path, name, tok}} : Maybe<&2, S.ParseErr>} {==} diff --git a/proofs/RepeatedLongFlag.bend b/proofs/RepeatedLongFlag.bend index 6f569e6..6e796bc 100644 --- a/proofs/RepeatedLongFlag.bend +++ b/proofs/RepeatedLongFlag.bend @@ -37,17 +37,20 @@ def repeated_long_flag.step( ) -> {D1.dead_of(S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen})) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>}: e1 = Equal.sym(S.St, S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen}), - S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen), + S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}), L1.long_arg_step(body, name, val, args, up, subs, path, bs, pos, seen, h_dd, h_cut, h_name)) %e1 : {D1.dead_of(_) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} e2 = Equal.sym(Maybe<&2, S.Arg>, S.by_long(args, name), Some{S.Arg{nn, sh, lo, S.Flag{}, hp, req, dflt, cs}}, h_found) - %e2 : {D1.dead_of(S.parse.take_long.found(_, name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen)) + %e2 : {D1.dead_of(S.parse.take_long.found(_, name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} e3 = Equal.sym(Bool, S.bound(bs, nn), True{}, h_again) - %e3 : {D1.dead_of(S.parse.once(_, S.parse.take_flag(val, nn, "--" ++ body, args, up, subs, path, bs, pos, - False{}, seen), nn, path)) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} - L2.once_dead(S.parse.take_flag(val, nn, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen), nn, path) + %e3 : {D1.dead_of(S.parse.once(_, + S.parse.take_flag(val, nn, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, + seen}), nn, path)) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} + L2.once_dead(S.parse.take_flag(val, nn, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}), nn, path) def Laws.repeated_long_flag( spec, diff --git a/proofs/RepeatedLongOpt.bend b/proofs/RepeatedLongOpt.bend index 86a7339..8d952a0 100644 --- a/proofs/RepeatedLongOpt.bend +++ b/proofs/RepeatedLongOpt.bend @@ -37,17 +37,18 @@ def repeated_long_opt.step( ) -> {D1.dead_of(S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen})) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>}: e1 = Equal.sym(S.St, S.parse.step("--" ++ body, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen}), - S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen), + S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}), L1.long_arg_step(body, name, val, args, up, subs, path, bs, pos, seen, h_dd, h_cut, h_name)) %e1 : {D1.dead_of(_) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} e2 = Equal.sym(Maybe<&2, S.Arg>, S.by_long(args, name), Some{S.Arg{nn, sh, lo, S.Opt{}, hp, req, dflt, cs}}, h_found) - %e2 : {D1.dead_of(S.parse.take_long.found(_, name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen)) + %e2 : {D1.dead_of(S.parse.take_long.found(_, name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen})) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} e3 = Equal.sym(Bool, S.bound(bs, nn), True{}, h_again) - %e3 : {D1.dead_of(S.parse.once(_, S.parse.take_opt(val, nn, args, up, subs, path, bs, pos, False{}, - seen), nn, path)) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} - L2.once_dead(S.parse.take_opt(val, nn, args, up, subs, path, bs, pos, False{}, seen), nn, path) + %e3 : {D1.dead_of(S.parse.once(_, S.parse.take_opt(val, nn, S.Here{args, up, subs, path, bs, pos, False{}, seen}), + nn, path)) == Some{S.Repeated{path, nn}} : Maybe<&2, S.ParseErr>} + L2.once_dead(S.parse.take_opt(val, nn, S.Here{args, up, subs, path, bs, pos, False{}, seen}), nn, path) def Laws.repeated_long_opt( spec, diff --git a/proofs/ShortClusterReadsLetters.bend b/proofs/ShortClusterReadsLetters.bend index 44f4911..13ca371 100644 --- a/proofs/ShortClusterReadsLetters.bend +++ b/proofs/ShortClusterReadsLetters.bend @@ -11,16 +11,19 @@ def Laws.short_step(cc, rest, args, up, subs, path, bs, pos, seen, h_dd, h_dash, +tok = "-" ++ SCon{cc, rest} +st = {S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e1 = Equal.sym(Bool, String.eq(tok, "--"), False{}, h_dd) - %e1 : {S.parse.step.end(_, tok, args, up, subs, path, bs, pos, seen) == S.cluster(SCon{cc, rest}, tok, st, + %e1 : {S.parse.step.end(_, tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) + == S.cluster(SCon{cc, rest}, tok, st, False{}) : S.St} e4 = Equal.sym(Cmp, String.order.go(SCon{cc, rest}, "elp", LT{}), LT{}, Eq.string_order_lt(SCon{cc, rest}, "elp")) - %e4 : {S.parse.step.help(Bool.and(Cmp.is_eq(_), Bool.not(seen)), tok, args, up, subs, path, bs, pos, seen) + %e4 : {S.parse.step.help(Bool.and(Cmp.is_eq(_), Bool.not(seen)), tok, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.cluster(SCon{cc, rest}, tok, st, False{}) : S.St} e3 = Equal.sym(Bool, Char.is_eq(cc, '-'), False{}, h_dash) - %e3 : {S.parse.step.kind.go(String.starts_with.go.if("", rest, _), True{}, tok, args, up, subs, path, bs, pos, seen) + %e3 : {S.parse.step.kind.go(String.starts_with.go.if("", rest, _), True{}, tok, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.cluster(SCon{cc, rest}, tok, st, False{}) : S.St} e5 = Equal.sym(Bool, S.short_help(SCon{cc, rest}, args, seen), False{}, h_help) - %e5 : {S.parse.take_short.go(_, SCon{cc, rest}, tok, args, up, subs, path, bs, pos, False{}, seen) + %e5 : {S.parse.take_short.go(_, SCon{cc, rest}, tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.cluster(SCon{cc, rest}, tok, st, False{}) : S.St} {==} @@ -53,12 +56,12 @@ def Laws.letter_flag( e0 = M1.cl.back(cc, rest, orig, args, up, subs, path, bs, pos, raw, seen, aa, h_found) %e0 : {_ == rhs : S.St} e1 = Equal.sym(Bool, String.starts_with(rest, "="), False{}, h_noeq) - %e1 : {S.cluster(rest, orig, S.parse.take_arg.kind(S.Flag{}, nn, S.cluster.val.flag(_, rest), orig, args, up, - subs, path, - bs, pos, raw, seen), _) == rhs : S.St} + %e1 : {S.cluster(rest, orig, + S.parse.take_arg.kind(S.Flag{}, nn, S.cluster.val.flag(_, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), _) == rhs : S.St} e2 = Equal.sym(Bool, S.bound(bs, nn), False{}, h_once) - %e2 : {S.cluster(rest, orig, S.parse.once(_, S.parse.take_flag(None{}, nn, orig, args, up, subs, path, bs, - pos, raw, seen), + %e2 : {S.cluster(rest, orig, + S.parse.once(_, S.parse.take_flag(None{}, nn, orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), nn, path), False{}) == rhs : S.St} {==} @@ -76,8 +79,9 @@ def ln.ty( +seen: Bool, +nn: String ) -> Type: - {S.cluster(SNil{}, orig, S.parse.take_arg.kind(kk, nn, S.cluster.val.kind(kk, SNil{}), orig, args, up, subs, - path, bs, pos, raw, seen), + {S.cluster(SNil{}, orig, + S.parse.take_arg.kind(kk, nn, S.cluster.val.kind(kk, SNil{}), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), S.cluster.ends.kind(kk, SNil{})) == S.St{S.Need{nn}, args, up, subs, path, bs, pos, raw, seen} : S.St} # a letter spelling an option that takes a value now, last in its word diff --git a/proofs/ValueBinds.bend b/proofs/ValueBinds.bend index f2e1477..da693bb 100644 --- a/proofs/ValueBinds.bend +++ b/proofs/ValueBinds.bend @@ -23,10 +23,10 @@ def value.step( ) -> {S.parse.step(tok, S.St{S.Need{name}, args, up, subs, path, bs, pos, raw, seen}) == S.St{S.Free{}, args, up, subs, path, S.Bind{name, tok} <> bs, pos, raw, seen} : S.St}: e1 = Equal.sym(Bool, S.looks_flag(tok), False{}, h_flag) - %e1 : {S.parse.step.need(_, name, tok, args, up, subs, path, bs, pos, raw, seen) + %e1 : {S.parse.step.need(_, name, tok, S.Here{args, up, subs, path, bs, pos, raw, seen}) == S.St{S.Free{}, args, up, subs, path, S.Bind{name, tok} <> bs, pos, raw, seen} : S.St} e2 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, name)), tok), True{}, h_ok) - %e2 : {S.parse.take_choice(_, name, tok, args, up, subs, path, bs, pos, raw, seen) + %e2 : {S.parse.take_choice(_, name, tok, S.Here{args, up, subs, path, bs, pos, raw, seen}) == S.St{S.Free{}, args, up, subs, path, S.Bind{name, tok} <> bs, pos, raw, seen} : S.St} {==} diff --git a/proofs/ValueFlagShaped.bend b/proofs/ValueFlagShaped.bend index 5bfff0b..c7bfd10 100644 --- a/proofs/ValueFlagShaped.bend +++ b/proofs/ValueFlagShaped.bend @@ -22,7 +22,7 @@ def value_flag_shaped.step( ) -> {D1.dead_of(S.parse.step(tok, S.St{S.Need{name}, args, up, subs, path, bs, pos, raw, seen})) == Some{S.NoValue{path, name}} : Maybe<&2, S.ParseErr>}: ee = Equal.sym(Bool, S.looks_flag(tok), True{}, h_flag) - %ee : {D1.dead_of(S.parse.step.need(_, name, tok, args, up, subs, path, bs, pos, raw, seen)) + %ee : {D1.dead_of(S.parse.step.need(_, name, tok, S.Here{args, up, subs, path, bs, pos, raw, seen})) == Some{S.NoValue{path, name}} : Maybe<&2, S.ParseErr>} {==} diff --git a/proofs/ValueRefused.bend b/proofs/ValueRefused.bend index 36f6810..6fb750c 100644 --- a/proofs/ValueRefused.bend +++ b/proofs/ValueRefused.bend @@ -23,10 +23,10 @@ def value_refused.step( ) -> {D1.dead_of(S.parse.step(tok, S.St{S.Need{name}, args, up, subs, path, bs, pos, raw, seen})) == Some{S.BadValue{path, name, tok}} : Maybe<&2, S.ParseErr>}: e1 = Equal.sym(Bool, S.looks_flag(tok), False{}, h_flag) - %e1 : {D1.dead_of(S.parse.step.need(_, name, tok, args, up, subs, path, bs, pos, raw, seen)) + %e1 : {D1.dead_of(S.parse.step.need(_, name, tok, S.Here{args, up, subs, path, bs, pos, raw, seen})) == Some{S.BadValue{path, name, tok}} : Maybe<&2, S.ParseErr>} e2 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, name)), tok), False{}, h_bad) - %e2 : {D1.dead_of(S.parse.take_choice(_, name, tok, args, up, subs, path, bs, pos, raw, seen)) + %e2 : {D1.dead_of(S.parse.take_choice(_, name, tok, S.Here{args, up, subs, path, bs, pos, raw, seen})) == Some{S.BadValue{path, name, tok}} : Maybe<&2, S.ParseErr>} {==} diff --git a/proofs/lemmas/ClusterEnd.bend b/proofs/lemmas/ClusterEnd.bend index 4c811e6..cf4ee26 100644 --- a/proofs/lemmas/ClusterEnd.bend +++ b/proofs/lemmas/ClusterEnd.bend @@ -32,25 +32,25 @@ def L2.unknown_short_step( h_help ): e1 = Equal.sym(Bool, String.eq("-" ++ SCon{cc, rest}, "--"), False{}, h_dd) - %e1 : {S.parse.step.end(_, "-" ++ SCon{cc, rest}, args, up, subs, path, bs, pos, - seen) == S.St{S.Dead{S.UnknownFlag{path, "-" ++ SCon{cc, + %e1 : {S.parse.step.end(_, "-" ++ SCon{cc, rest}, S.Here{args, up, subs, path, bs, pos, False{}, seen}) + == S.St{S.Dead{S.UnknownFlag{path, "-" ++ SCon{cc, rest}}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e4 = Equal.sym(Cmp, String.order.go(SCon{cc, rest}, "elp", LT{}), LT{}, Eq.string_order_lt(SCon{cc, rest}, "elp")) - %e4 : {S.parse.step.help(Bool.and(Cmp.is_eq(_), Bool.not(seen)), "-" ++ SCon{cc, rest}, args, up, subs, path, bs, - pos, seen) == S.St{S.Dead{S.UnknownFlag{path, "-" ++ SCon{cc, + %e4 : {S.parse.step.help(Bool.and(Cmp.is_eq(_), Bool.not(seen)), "-" ++ SCon{cc, rest}, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Dead{S.UnknownFlag{path, "-" ++ SCon{cc, rest}}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e3 = Equal.sym(Bool, Char.is_eq(cc, '-'), False{}, h_dash) - %e3 : {S.parse.step.kind.go(String.starts_with.go.if("", rest, _), True{}, "-" ++ SCon{cc, rest}, args, up, - subs, path, bs, pos, - seen) == S.St{S.Dead{S.UnknownFlag{path, "-" ++ SCon{cc, + %e3 : {S.parse.step.kind.go(String.starts_with.go.if("", rest, _), True{}, "-" ++ SCon{cc, rest}, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Dead{S.UnknownFlag{path, "-" ++ SCon{cc, rest}}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e5 = Equal.sym(Bool, S.short_help(SCon{cc, rest}, args, seen), False{}, h_help) - %e5 : {S.parse.take_short.go(_, SCon{cc, rest}, "-" ++ SCon{cc, rest}, args, up, subs, path, bs, pos, False{}, seen) + %e5 : {S.parse.take_short.go(_, SCon{cc, rest}, "-" ++ SCon{cc, rest}, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Dead{S.UnknownFlag{path, "-" ++ SCon{cc, rest}}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e2 = Equal.sym(Maybe<&2, S.Arg>, S.by_short(args, SCon{cc, SNil{}}), None{}, h_none) %e2 : {S.cluster(rest, "-" ++ SCon{cc, rest}, - S.parse.take_arg(_, S.cluster.val(_, rest), "-" ++ SCon{cc, rest}, args, up, subs, path, bs, pos, - False{}, seen), + S.parse.take_arg(_, S.cluster.val(_, rest), "-" ++ SCon{cc, rest}, + S.Here{args, up, subs, path, bs, pos, False{}, seen}), S.cluster.ends(_, rest)) == S.St{S.Dead{S.UnknownFlag{path, "-" ++ SCon{cc, rest}}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} L1.cluster_done(rest, "-" ++ SCon{cc, rest}, S.St{S.Dead{S.UnknownFlag{path, "-" ++ SCon{cc, rest}}}, args, @@ -91,8 +91,8 @@ def lb.ty( +seen: Bool, +nn: String ) -> Type: - {S.cluster(rest, orig, S.parse.take_arg.kind(kk, nn, S.cluster.val.kind(kk, rest), orig, args, up, subs, path, - bs, pos, raw, seen), + {S.cluster(rest, orig, + S.parse.take_arg.kind(kk, nn, S.cluster.val.kind(kk, rest), orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), S.cluster.ends.kind(kk, rest)) == S.St{S.Dead{S.BadValue{path, nn, rest}}, args, up, subs, path, bs, pos, raw, seen} : S.St} @@ -119,33 +119,36 @@ def lb( case S.Opt{}: +T = {S.St{S.Dead{S.BadValue{path, nn, rest}}, args, up, subs, path, bs, pos, raw, seen} : S.St} e1 = Equal.sym(Bool, String.starts_with(rest, "="), False{}, h_noeq) - %e1 : {S.cluster(rest, orig, S.parse.take_arg.kind(S.Opt{}, nn, S.short_of.val(_, rest), orig, args, up, - subs, path, bs, pos, raw, seen), True{}) + %e1 : {S.cluster(rest, orig, + S.parse.take_arg.kind(S.Opt{}, nn, S.short_of.val(_, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} e2 = Equal.sym(Bool, String.is_empty(rest), False{}, h_some) %e2 : {S.cluster(rest, orig, S.parse.take_arg.kind(S.Opt{}, nn, Bool.pick(Maybe<&2, String>, _, None{}, - Some{rest}), orig, args, up, subs, path, bs, pos, raw, seen), True{}) == T : S.St} + Some{rest}), orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} e3 = Equal.sym(Bool, S.bound(bs, nn), False{}, Walk.wk.not_true(S.bound(bs, nn), h_kind)) - %e3 : {S.cluster(rest, orig, S.parse.once(_, S.parse.take_opt(Some{rest}, nn, args, up, subs, path, bs, - pos, raw, seen), nn, path), True{}) == T + %e3 : {S.cluster(rest, orig, + S.parse.once(_, S.parse.take_opt(Some{rest}, nn, S.Here{args, up, subs, path, bs, pos, raw, seen}), nn, + path), True{}) == T : S.St} e4 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, nn)), rest), False{}, h_ok) - %e4 : {S.cluster(rest, orig, S.parse.take_choice(_, nn, rest, args, up, subs, path, bs, pos, raw, seen), + %e4 : {S.cluster(rest, orig, S.parse.take_choice(_, nn, rest, S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} L1.cluster_done(rest, orig, T) case S.Many{}: +T = {S.St{S.Dead{S.BadValue{path, nn, rest}}, args, up, subs, path, bs, pos, raw, seen} : S.St} e1 = Equal.sym(Bool, String.starts_with(rest, "="), False{}, h_noeq) - %e1 : {S.cluster(rest, orig, S.parse.take_arg.kind(S.Many{}, nn, S.short_of.val(_, rest), orig, args, up, - subs, path, bs, pos, raw, seen), True{}) + %e1 : {S.cluster(rest, orig, + S.parse.take_arg.kind(S.Many{}, nn, S.short_of.val(_, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} e2 = Equal.sym(Bool, String.is_empty(rest), False{}, h_some) %e2 : {S.cluster(rest, orig, S.parse.take_arg.kind(S.Many{}, nn, Bool.pick(Maybe<&2, String>, _, None{}, - Some{rest}), orig, args, up, subs, path, bs, pos, raw, seen), True{}) == T : S.St} + Some{rest}), orig, S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} e4 = Equal.sym(Bool, S.allowed(S.parse.choices(S.by_name(args, nn)), rest), False{}, h_ok) - %e4 : {S.cluster(rest, orig, S.parse.take_choice(_, nn, rest, args, up, subs, path, bs, pos, raw, seen), + %e4 : {S.cluster(rest, orig, S.parse.take_choice(_, nn, rest, S.Here{args, up, subs, path, bs, pos, raw, seen}), True{}) == T : S.St} L1.cluster_done(rest, orig, T) case S.Flag{}: diff --git a/proofs/lemmas/ClusterSteps.bend b/proofs/lemmas/ClusterSteps.bend index ca90c2f..24bc437 100644 --- a/proofs/lemmas/ClusterSteps.bend +++ b/proofs/lemmas/ClusterSteps.bend @@ -20,14 +20,16 @@ def cl.step( +aa: S.Arg, h_found: {S.by_short(args, SCon{cc, SNil{}}) == Some{aa} : Maybe<&2, S.Arg>} ) -> {S.cluster(SCon{cc, rest}, orig, S.St{S.Free{}, args, up, subs, path, bs, pos, raw, seen}, False{}) - == S.cluster(rest, orig, S.parse.take_arg(Some{aa}, S.cluster.val(Some{aa}, rest), orig, args, up, subs, - path, bs, pos, - raw, seen), S.cluster.ends(Some{aa}, rest)) : S.St}: + == S.cluster(rest, orig, + S.parse.take_arg(Some{aa}, S.cluster.val(Some{aa}, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), S.cluster.ends(Some{aa}, rest)) : S.St}: ee = Equal.sym(Maybe<&2, S.Arg>, S.by_short(args, SCon{cc, SNil{}}), Some{aa}, h_found) - %ee : {S.cluster(rest, orig, S.parse.take_arg(_, S.cluster.val(_, rest), orig, args, up, subs, path, bs, pos, raw, - seen), S.cluster.ends(_, rest)) - == S.cluster(rest, orig, S.parse.take_arg(Some{aa}, S.cluster.val(Some{aa}, rest), orig, args, up, subs, path, bs, - pos, raw, seen), S.cluster.ends(Some{aa}, rest)) : S.St} + %ee : {S.cluster(rest, orig, + S.parse.take_arg(_, S.cluster.val(_, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), S.cluster.ends(_, rest)) + == S.cluster(rest, orig, + S.parse.take_arg(Some{aa}, S.cluster.val(Some{aa}, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), S.cluster.ends(Some{aa}, rest)) : S.St} {==} # the same, the other way round, for rewriting a goal about the cluster @@ -45,11 +47,11 @@ def cl.back( +seen: Bool, +aa: S.Arg, h_found: {S.by_short(args, SCon{cc, SNil{}}) == Some{aa} : Maybe<&2, S.Arg>} -) -> {S.cluster(rest, orig, S.parse.take_arg(Some{aa}, S.cluster.val(Some{aa}, rest), orig, args, up, subs, - path, bs, pos, - raw, seen), S.cluster.ends(Some{aa}, rest)) +) -> {S.cluster(rest, orig, + S.parse.take_arg(Some{aa}, S.cluster.val(Some{aa}, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), S.cluster.ends(Some{aa}, rest)) == S.cluster(SCon{cc, rest}, orig, S.St{S.Free{}, args, up, subs, path, bs, pos, raw, seen}, False{}) : S.St}: Equal.sym(S.St, S.cluster(SCon{cc, rest}, orig, S.St{S.Free{}, args, up, subs, path, bs, pos, raw, seen}, False{}), - S.cluster(rest, orig, S.parse.take_arg(Some{aa}, S.cluster.val(Some{aa}, rest), orig, args, up, subs, path, bs, pos, - raw, seen), S.cluster.ends(Some{aa}, rest)), + S.cluster(rest, orig, S.parse.take_arg(Some{aa}, S.cluster.val(Some{aa}, rest), orig, + S.Here{args, up, subs, path, bs, pos, raw, seen}), S.cluster.ends(Some{aa}, rest)), cl.step(cc, rest, orig, args, up, subs, path, bs, pos, raw, seen, aa, h_found)) diff --git a/proofs/lemmas/HelpPathWalk.bend b/proofs/lemmas/HelpPathWalk.bend index 571d388..b4694e7 100644 --- a/proofs/lemmas/HelpPathWalk.bend +++ b/proofs/lemmas/HelpPathWalk.bend @@ -66,9 +66,10 @@ def hp.cons( +k3 = {k2 : List<&2, S.Sub>} +mid = {S.St{S.Help{}, args, up, kids, List.append(&2, String, path, [nn]), bs, pos, raw, seen} : S.St} +fin_st = {S.St{S.Help{}, args, up, k3, List.append(&2, String, path, nn <> tt), bs, pos, raw, seen} : S.St} - es = Equal.cong(Maybe<&2, S.Sub>, S.St, mm => S.parse.walk(tt, S.parse.step.help_path(mm, nn, args, up, subs, - path, bs, - pos, raw, seen)), S.find_sub(subs, nn), Some{S.Sub{sn, sa, sg, kids}}, e_fm) + es = Equal.cong(Maybe<&2, S.Sub>, S.St, + mm => S.parse.walk(tt, + S.parse.step.help_path(mm, nn, + S.Here{args, up, subs, path, bs, pos, raw, seen})), S.find_sub(subs, nn), Some{S.Sub{sn, sa, sg, kids}}, e_fm) (k3, Equal.trans(S.St, S.parse.walk(nn <> tt, S.St{S.Help{}, args, up, subs, path, bs, pos, raw, seen}), S.parse.walk(tt, mid), fin_st, es, Equal.trans(S.St, S.parse.walk(tt, mid), diff --git a/proofs/lemmas/WalkSteps.bend b/proofs/lemmas/WalkSteps.bend index 8275559..ebffd55 100644 --- a/proofs/lemmas/WalkSteps.bend +++ b/proofs/lemmas/WalkSteps.bend @@ -51,25 +51,25 @@ def L5.unknown_long_step( h_lh ): e1 = Equal.sym(Bool, String.eq("--" ++ body, "--"), False{}, h_dd) - %e1 : {S.parse.step.end(_, "--" ++ body, args, up, subs, path, bs, pos, seen) + %e1 : {S.parse.step.end(_, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Dead{S.UnknownFlag{path, "--" ++ body}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e0 = Equal.sym(Bool, String.starts_with(body, ""), True{}, L3.prefix_empty(body)) - %e0 : {S.parse.step.kind.go(_, True{}, "--" ++ body, args, up, subs, path, bs, pos, seen) + %e0 : {S.parse.step.kind.go(_, True{}, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Dead{S.UnknownFlag{path, "--" ++ body}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} ed = Equal.sym(String, String.drop(body, 0n), body, L1.drop_zero(body)) - %ed : {S.parse.take_long(_, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen) + %ed : {S.parse.take_long(_, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Dead{S.UnknownFlag{path, "--" ++ body}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e2 = Equal.sym(String & Maybe<&2, String>, S.cut_eq(body), (name, val), h_cut) - %e2 : {S.parse.take_long.cut(_, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen) + %e2 : {S.parse.take_long.cut(_, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Dead{S.UnknownFlag{path, "--" ++ body}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e3 = Equal.sym(Bool, String.is_empty(name), False{}, h_name) - %e3 : {S.parse.take_long.named(_, name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen) + %e3 : {S.parse.take_long.named(_, name, val, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Dead{S.UnknownFlag{path, "--" ++ body}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e4 = Equal.sym(Maybe<&2, S.Arg>, S.by_long(args, name), None{}, h_none) - %e4 : {S.parse.take_long.found(_, name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen) + %e4 : {S.parse.take_long.found(_, name, val, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Dead{S.UnknownFlag{path, "--" ++ body}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} e5 = Equal.sym(Bool, S.long_help(name, val, seen), False{}, h_lh) - %e5 : {S.parse.take_long.help(_, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen) + %e5 : {S.parse.take_long.help(_, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == S.St{S.Dead{S.UnknownFlag{path, "--" ++ body}}, args, up, subs, path, bs, pos, False{}, seen} : S.St} {==} @@ -127,25 +127,25 @@ def L2.long_arg_step( h_name ): e1 = Equal.sym(Bool, String.eq("--" ++ body, "--"), False{}, h_dd) - %e1 : {S.parse.step.end(_, "--" ++ body, args, up, subs, path, bs, pos, seen) - == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen) : S.St} + %e1 : {S.parse.step.end(_, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) + == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St} e0 = Equal.sym(Bool, String.starts_with(body, ""), True{}, L3.prefix_empty(body)) - %e0 : {S.parse.step.kind.go(_, True{}, "--" ++ body, args, up, subs, path, bs, pos, seen) - == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen) : S.St} + %e0 : {S.parse.step.kind.go(_, True{}, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) + == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St} ed = Equal.sym(String, String.drop(body, 0n), body, L1.drop_zero(body)) - %ed : {S.parse.take_long(_, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen) - == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen) : S.St} + %ed : {S.parse.take_long(_, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) + == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St} e2 = Equal.sym(String & Maybe<&2, String>, S.cut_eq(body), (name, val), h_cut) - %e2 : {S.parse.take_long.cut(_, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen) - == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen) : S.St} + %e2 : {S.parse.take_long.cut(_, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) + == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St} e3 = Equal.sym(Bool, String.is_empty(name), False{}, h_name) - %e3 : {S.parse.take_long.named(_, name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, seen) - == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, args, up, subs, path, bs, pos, False{}, - seen) : S.St} + %e3 : {S.parse.take_long.named(_, name, val, "--" ++ body, S.Here{args, up, subs, path, bs, pos, False{}, seen}) + == S.parse.take_long.found(S.by_long(args, name), name, val, "--" ++ body, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St} {==} # the walk through `tok` is one step from where the words before it stood @@ -185,9 +185,9 @@ def pos.take( S.parse.take_pos.keep(S.rest.is(S.Arg{name, sh, lo, kind, hp, req, dflt, cs}), S.Arg{name, sh, lo, kind, hp, req, dflt, cs}, rest), raw, True{}} : S.St}: e2 = Equal.sym(Bool, S.allowed(cs, tok), True{}, h_ok) - %e2 : {S.parse.take_choice(_, name, tok, args, up, subs, path, bs, - S.parse.take_pos.keep(S.rest.is(S.Arg{name, sh, lo, kind, hp, req, dflt, cs}), - S.Arg{name, sh, lo, kind, hp, req, dflt, cs}, rest), raw, True{}) + %e2 : {S.parse.take_choice(_, name, tok, + S.Here{args, up, subs, path, bs, S.parse.take_pos.keep(S.rest.is(S.Arg{name, sh, lo, kind, hp, req, dflt, cs}), + S.Arg{name, sh, lo, kind, hp, req, dflt, cs}, rest), raw, True{}}) == S.St{S.Free{}, args, up, subs, path, S.Bind{name, tok} <> bs, S.parse.take_pos.keep(S.rest.is(S.Arg{name, sh, lo, kind, hp, req, dflt, cs}), S.Arg{name, sh, lo, kind, hp, req, dflt, cs}, rest), raw, True{}} : S.St} @@ -259,16 +259,18 @@ def enter.word( h_help: {String.eq(tok, "help") == False{} : Bool}, +h_dash: {String.starts_with(tok, "-") == False{} : Bool} ) -> {S.parse.step(tok, S.St{S.Free{}, args, up, subs, path, bs, pos, False{}, seen}) - == S.parse.word.go(S.find_sub(subs, tok), tok, args, up, subs, path, bs, pos, False{}, seen) : S.St}: - +rhs = S.parse.word.go(S.find_sub(subs, tok), tok, args, up, subs, path, bs, pos, False{}, seen) + == S.parse.word.go(S.find_sub(subs, tok), tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St}: + +rhs = S.parse.word.go(S.find_sub(subs, tok), tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) e1 = Equal.sym(Bool, String.eq(tok, "--"), False{}, h_dd) - %e1 : {S.parse.step.end(_, tok, args, up, subs, path, bs, pos, seen) == rhs : S.St} + %e1 : {S.parse.step.end(_, tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == rhs : S.St} e2 = Equal.sym(Bool, String.eq(tok, "help"), False{}, h_help) - %e2 : {S.parse.step.help(Bool.and(_, Bool.not(seen)), tok, args, up, subs, path, bs, pos, seen) == rhs : S.St} + %e2 : {S.parse.step.help(Bool.and(_, Bool.not(seen)), tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) + == rhs : S.St} e3 = Equal.sym(Bool, String.starts_with(tok, "--"), False{}, Walk.wk.dash(tok, h_dash)) - %e3 : {S.parse.step.kind.go(_, String.starts_with(tok, "-"), tok, args, up, subs, path, bs, pos, seen) == rhs : S.St} + %e3 : {S.parse.step.kind.go(_, String.starts_with(tok, "-"), tok, + S.Here{args, up, subs, path, bs, pos, False{}, seen}) == rhs : S.St} e4 = Equal.sym(Bool, String.starts_with(tok, "-"), False{}, h_dash) - %e4 : {S.parse.step.kind.go(False{}, _, tok, args, up, subs, path, bs, pos, seen) == rhs : S.St} + %e4 : {S.parse.step.kind.go(False{}, _, tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) == rhs : S.St} {==} # a found subcommand, entered or refused, as the first blocking positional says @@ -283,9 +285,9 @@ def enter.go( +seen: Bool, +sub: S.Sub, h_sub: {S.find_sub(subs, tok) == Some{sub} : Maybe<&2, S.Sub>} -) -> {S.parse.word.go(S.find_sub(subs, tok), tok, args, up, subs, path, bs, pos, False{}, seen) - == S.parse.enter_or(S.parse.first_req(pos), sub, args, up, subs, path, bs, pos, False{}, seen) : S.St}: +) -> {S.parse.word.go(S.find_sub(subs, tok), tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) + == S.parse.enter_or(S.parse.first_req(pos), sub, S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St}: ee = Equal.sym(Maybe<&2, S.Sub>, S.find_sub(subs, tok), Some{sub}, h_sub) - %ee : {S.parse.word.go(_, tok, args, up, subs, path, bs, pos, False{}, seen) - == S.parse.enter_or(S.parse.first_req(pos), sub, args, up, subs, path, bs, pos, False{}, seen) : S.St} + %ee : {S.parse.word.go(_, tok, S.Here{args, up, subs, path, bs, pos, False{}, seen}) + == S.parse.enter_or(S.parse.first_req(pos), sub, S.Here{args, up, subs, path, bs, pos, False{}, seen}) : S.St} {==} diff --git a/src/cli.bend b/src/cli.bend index 43764f4..3b6d770 100644 --- a/src/cli.bend +++ b/src/cli.bend @@ -108,6 +108,22 @@ type St is Data: seen: Bool } +# all of the walker but its mode: the current command's arguments, the +# commands above it, its subcommands, the selected path, its own bindings, +# the positionals left, whether `--` has been read, and whether a positional +# of the current command has been bound +type Here is Data: + Here{ + args: List<&2, Arg>, + up: List<&2, Level>, + subs: List<&2, Sub>, + path: List<&2, String>, + binds: List<&2, Bind>, + pos: List<&2, Arg>, + raw: Bool, + seen: Bool + } + # the page a help walk has reached type How is Data: How{ @@ -573,33 +589,53 @@ def parse.start(app: Cli) -> St: Cli{_n, _a, _v, +args, subs} = app St{Free{}, args, [], subs, [], [], pos_of(args), False{}, False{}} +# the walker in a mode, with the rest of its state +def parse.at(mode: Mode, hh: Here) -> St: + Here{args, up, subs, path, binds, pos, raw, seen} = hh + St{mode, args, up, subs, path, binds, pos, raw, seen} + +# the current command's arguments +def here.args(hh: Here) -> List<&2, Arg>: + Here{args, _g, _s, _p, _b, _o, _r, _n} = hh + args + +# the commands above the current one +def here.up(hh: Here) -> List<&2, Level>: + Here{_a, up, _s, _p, _b, _o, _r, _n} = hh + up + +# the current command's subcommands +def here.subs(hh: Here) -> List<&2, Sub>: + Here{_a, _g, subs, _p, _b, _o, _r, _n} = hh + subs + +# the selected path +def here.path(hh: Here) -> List<&2, String>: + Here{_a, _g, _s, path, _b, _o, _r, _n} = hh + path + +# the current command's own bindings +def here.binds(hh: Here) -> List<&2, Bind>: + Here{_a, _g, _s, _p, binds, _o, _r, _n} = hh + binds + +# the positionals left +def here.pos(hh: Here) -> List<&2, Arg>: + Here{_a, _g, _s, _p, _b, pos, _r, _n} = hh + pos + +# whether a positional of the current command has been bound +def here.seen(hh: Here) -> Bool: + Here{_a, _g, _s, _p, _b, _o, _r, seen} = hh + seen + # a failed walker that keeps the rest of the state -def parse.dead( - ee: ParseErr, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: - St{Dead{ee}, args, up, subs, path, binds, pos, raw, seen} +def parse.dead(ee: ParseErr, hh: Here) -> St: + parse.at(Dead{ee}, hh) # a successful bind of `name` to `val` -def parse.put( - +name: String, - +val: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.put(+name: String, +val: String, hh: Here) -> St: + Here{args, up, subs, path, binds, pos, raw, seen} = hh St{Free{}, args, up, subs, path, Bind{name, val} <> binds, pos, raw, seen} # the choices of a found Arg, or none @@ -612,81 +648,34 @@ def parse.choices(mm: Maybe<&2, Arg>) -> List<&2, String>: cs # bind `name` to `val` when the value is allowed -def parse.take_choice( - ok: Bool, - +name: String, - +val: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.take_choice(ok: Bool, +name: String, +val: String, +hh: Here) -> St: match ok: case True{}: - parse.put(name, val, args, up, subs, path, binds, pos, raw, seen) + parse.put(name, val, hh) case False{}: - parse.dead(BadValue{path, name, val}, args, up, subs, path, binds, pos, raw, seen) + parse.dead(BadValue{here.path(hh), name, val}, hh) # bind an option that already has its value, checked against the choices of # the current command's argument of that name: a parent's argument of the same # name has its own -def parse.take_opt_val( - +name: String, - +val: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: - parse.take_choice(allowed(parse.choices(by_name(args, name)), val), name, val, - args, up, subs, path, binds, pos, raw, seen) +def parse.take_opt_val(+name: String, +val: String, +hh: Here) -> St: + parse.take_choice(allowed(parse.choices(by_name(here.args(hh), name)), val), name, val, hh) # a flag with no glued value is set; a glued value is unexpected -def parse.take_flag( - val: Maybe<&2, String>, - +name: String, - +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.take_flag(val: Maybe<&2, String>, +name: String, +orig: String, +hh: Here) -> St: match val: case None{}: - parse.put(name, "true", args, up, subs, path, binds, pos, raw, seen) + parse.put(name, "true", hh) case Some{_v}: - parse.dead(Unexpected{path, orig}, args, up, subs, path, binds, pos, raw, seen) + parse.dead(Unexpected{here.path(hh), orig}, hh) # an option: glued value now, or the next token -def parse.take_opt( - val: Maybe<&2, String>, - +name: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.take_opt(val: Maybe<&2, String>, +name: String, +hh: Here) -> St: match val: case None{}: - St{Need{name}, args, up, subs, path, binds, pos, raw, seen} + parse.at(Need{name}, hh) case Some{v}: - parse.take_opt_val(name, v, args, up, subs, path, binds, pos, raw, seen) + parse.take_opt_val(name, v, hh) # a flag or single-valued option given again is refused, whatever the walk # would have done with it; the walker keeps the rest of its state @@ -704,50 +693,30 @@ def parse.take_arg.kind( +name: String, val: Maybe<&2, String>, +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool + +hh: Here ) -> St: match kk: case Flag{}: - parse.once(bound(binds, name), parse.take_flag(val, name, orig, args, up, subs, path, - binds, pos, raw, seen), name, path) + parse.once(bound(here.binds(hh), name), parse.take_flag(val, name, orig, hh), name, + here.path(hh)) case Opt{}: - parse.once(bound(binds, name), parse.take_opt(val, name, args, up, subs, path, binds, pos, - raw, seen), name, path) + parse.once(bound(here.binds(hh), name), parse.take_opt(val, name, hh), name, + here.path(hh)) case Many{}: - parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen) + parse.take_opt(val, name, hh) case Pos{}: - parse.dead(UnknownFlag{path, orig}, args, up, subs, path, binds, pos, raw, seen) + parse.dead(UnknownFlag{here.path(hh), orig}, hh) case Rest{}: - parse.dead(UnknownFlag{path, orig}, args, up, subs, path, binds, pos, raw, seen) + parse.dead(UnknownFlag{here.path(hh), orig}, hh) # a found Arg, or an unknown flag -def parse.take_arg( - found: Maybe<&2, Arg>, - val: Maybe<&2, String>, - +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.take_arg(found: Maybe<&2, Arg>, val: Maybe<&2, String>, +orig: String, +hh: Here) -> St: match found: case None{}: - parse.dead(UnknownFlag{path, orig}, args, up, subs, path, binds, pos, raw, seen) + parse.dead(UnknownFlag{here.path(hh), orig}, hh) case Some{a}: Arg{+name, _s, _l, kind, _h, _r, _d, _c} = a - parse.take_arg.kind(kind, name, val, orig, args, up, subs, path, binds, pos, - raw, seen) + parse.take_arg.kind(kind, name, val, orig, hh) # whether an unknown long option is a request for help: a bare `--help`, # with no `=` value, before any positional of the current command is bound @@ -760,23 +729,12 @@ def long_help(+name: String, val: Maybe<&2, String>, seen: Bool) -> Bool: # an unknown long option: a request for help (`--help`, as `help`), or an # unknown flag -def parse.take_long.help( - hit: Bool, - +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.take_long.help(hit: Bool, +orig: String, +hh: Here) -> St: match hit: case True{}: - St{Help{}, args, up, subs, path, binds, pos, raw, seen} + parse.at(Help{}, hh) case False{}: - parse.dead(UnknownFlag{path, orig}, args, up, subs, path, binds, pos, raw, seen) + parse.dead(UnknownFlag{here.path(hh), orig}, hh) # a long option the current command spells, or an unknown one def parse.take_long.found( @@ -784,21 +742,13 @@ def parse.take_long.found( +name: String, val: Maybe<&2, String>, +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool + +hh: Here ) -> St: match found: case None{}: - parse.take_long.help(long_help(name, val, seen), orig, args, up, subs, path, - binds, pos, raw, seen) + parse.take_long.help(long_help(name, val, here.seen(hh)), orig, hh) case Some{a}: - parse.take_arg(Some{a}, val, orig, args, up, subs, path, binds, pos, raw, seen) + parse.take_arg(Some{a}, val, orig, hh) # a long option with a name, or `--=...` def parse.take_long.named( @@ -806,54 +756,22 @@ def parse.take_long.named( +name: String, val: Maybe<&2, String>, +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool + +hh: Here ) -> St: match empty: case True{}: - parse.dead(UnknownFlag{path, orig}, args, up, subs, path, binds, pos, raw, seen) + parse.dead(UnknownFlag{here.path(hh), orig}, hh) case False{}: - parse.take_long.found(by_long(args, name), name, val, orig, args, up, subs, - path, binds, pos, raw, seen) + parse.take_long.found(by_long(here.args(hh), name), name, val, orig, hh) # a long option after the `=` cut -def parse.take_long.cut( - nv: String & Maybe<&2, String>, - +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.take_long.cut(nv: String & Maybe<&2, String>, +orig: String, hh: Here) -> St: (+name, val) = nv - parse.take_long.named(String.is_empty(name), name, val, orig, args, up, subs, - path, binds, pos, raw, seen) + parse.take_long.named(String.is_empty(name), name, val, orig, hh) # a long option body after `--` -def parse.take_long( - body: String, - +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: - parse.take_long.cut(cut_eq(body), orig, args, up, subs, path, binds, pos, raw, - seen) +def parse.take_long(body: String, +orig: String, hh: Here) -> St: + parse.take_long.cut(cut_eq(body), orig, hh) # a flag's value in a cluster: the rest when it starts with `=` (which # `take_arg` refuses), else none, so the next letter goes on @@ -915,32 +833,18 @@ def cluster.ends(found: Maybe<&2, Arg>, +rest: String) -> Bool: # one letter against a walker an earlier letter failed changes nothing; # otherwise it goes through `take_arg` -def cluster.apply.mode( - mode: Mode, - +cc: Char, - +rest: String, - +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def cluster.apply.mode(mode: Mode, +cc: Char, +rest: String, +orig: String, +hh: Here) -> St: match mode: case Dead{e}: - St{Dead{e}, args, up, subs, path, binds, pos, raw, seen} + parse.at(Dead{e}, hh) case _other: - +found = by_short(args, SCon{cc, SNil{}}) - parse.take_arg(found, cluster.val(found, rest), orig, args, up, subs, path, binds, pos, - raw, seen) + +found = by_short(here.args(hh), SCon{cc, SNil{}}) + parse.take_arg(found, cluster.val(found, rest), orig, hh) # one letter against the walker def cluster.apply(st: St, +cc: Char, +rest: String, +orig: String) -> St: St{mode, +args, +up, +subs, +path, +binds, +pos, +raw, +seen} = st - cluster.apply.mode(mode, cc, rest, orig, args, up, subs, path, binds, pos, raw, seen) + cluster.apply.mode(mode, cc, rest, orig, Here{args, up, subs, path, binds, pos, raw, seen}) # one letter of a cluster, unless an earlier one ended it def cluster.letter(done: Bool, +cc: Char, +rest: String, +orig: String, st: St) -> St: @@ -979,39 +883,16 @@ def short_help(+body: String, +args: List<&2, Arg>, seen: Bool) -> Bool: Bool.and(Maybe.is_none(&2, Arg, by_short(args, "h")), Maybe.is_none(&2, Arg, by_long(args, "help"))))) # a request for help (`-h`, as `help`), or a cluster of short options -def parse.take_short.go( - hit: Bool, - body: String, - +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.take_short.go(hit: Bool, body: String, +orig: String, +hh: Here) -> St: match hit: case True{}: - St{Help{}, args, up, subs, path, binds, pos, raw, seen} + parse.at(Help{}, hh) case False{}: - cluster(body, orig, St{Free{}, args, up, subs, path, binds, pos, raw, seen}, False{}) + cluster(body, orig, parse.at(Free{}, hh), False{}) # a short option body after `-` -def parse.take_short( - +body: String, - +orig: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: - parse.take_short.go(short_help(body, args, seen), body, orig, args, up, subs, path, binds, pos, raw, seen) +def parse.take_short(+body: String, +orig: String, +hh: Here) -> St: + parse.take_short.go(short_help(body, here.args(hh), here.seen(hh)), body, orig, hh) # a rest positional stays; a plain one is consumed def parse.take_pos.keep(keep: Bool, hh: Arg, tt: List<&2, Arg>) -> List<&2, Arg>: @@ -1034,11 +915,11 @@ def parse.take_pos( ) -> St: match pos: case Nil{}: - parse.dead(Unexpected{path, tok}, args, up, subs, path, binds, pos, raw, True{}) + parse.dead(Unexpected{path, tok}, Here{args, up, subs, path, binds, pos, raw, True{}}) case Con{+h, t}: Arg{+name, _s, _l, _k, _h, _r, _d, +cs} = h - parse.take_choice(allowed(cs, tok), name, tok, args, up, subs, path, binds, - parse.take_pos.keep(rest.is(h), h, t), raw, True{}) + parse.take_choice(allowed(cs, tok), name, tok, Here{args, up, subs, path, binds, parse.take_pos.keep(rest.is(h), + h, t), raw, True{}}) # this Sub's arguments become current, with no bindings of its own; the # command it leaves keeps its arguments and bindings above it @@ -1091,258 +972,115 @@ def parse.first_req(pos: List<&2, Arg>) -> Maybe<&2, String>: parse.first_req.at(parse.first_req.skip(rest.is(h), h), parse.first_req(t)) # a leftover required positional blocks entering a subcommand -def parse.enter_or( - miss: Maybe<&2, String>, - ss: Sub, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.enter_or(miss: Maybe<&2, String>, ss: Sub, +hh: Here) -> St: match miss: case None{}: - parse.enter(ss, args, up, path, binds) + parse.enter(ss, here.args(hh), here.up(hh), here.path(hh), here.binds(hh)) case Some{n}: - parse.dead(Missing{path, n}, args, up, subs, path, binds, pos, raw, seen) + parse.dead(Missing{here.path(hh), n}, hh) # a found subcommand, or a positional -def parse.word.go( - found: Maybe<&2, Sub>, - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.word.go(found: Maybe<&2, Sub>, +tok: String, +hh: Here) -> St: match found: case None{}: + Here{args, up, subs, path, binds, pos, raw, _n} = hh parse.take_pos(tok, args, up, subs, path, binds, pos, raw) case Some{s}: - parse.enter_or(parse.first_req(pos), s, args, up, subs, path, binds, pos, raw, - seen) + parse.enter_or(parse.first_req(here.pos(hh)), s, hh) # a word: a subcommand, or a positional -def parse.word( - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: - parse.word.go(find_sub(subs, tok), tok, args, up, subs, path, binds, pos, - raw, seen) +def parse.word(+tok: String, +hh: Here) -> St: + parse.word.go(find_sub(here.subs(hh), tok), tok, hh) # `-` as a word, or a short option -def parse.step.short.go( - alone: Bool, - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +seen: Bool -) -> St: +def parse.step.short.go(alone: Bool, +tok: String, +hh: Here) -> St: match alone: case True{}: - parse.word(tok, args, up, subs, path, binds, pos, False{}, seen) + parse.word(tok, hh) case False{}: - parse.take_short(String.drop(tok, 1n), tok, args, up, subs, path, binds, pos, - False{}, seen) + parse.take_short(String.drop(tok, 1n), tok, hh) # `-` alone is a positional; otherwise a short option -def parse.step.short( - dash: Bool, - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +seen: Bool -) -> St: +def parse.step.short(dash: Bool, +tok: String, +hh: Here) -> St: match dash: case True{}: - parse.step.short.go(String.is_empty(String.drop(tok, 1n)), tok, args, up, subs, path, binds, - pos, seen) + parse.step.short.go(String.is_empty(String.drop(tok, 1n)), tok, hh) case False{}: - parse.word(tok, args, up, subs, path, binds, pos, False{}, seen) + parse.word(tok, hh) # `--long` first, then `-s`, then a word -def parse.step.kind.go( - long: Bool, - dash: Bool, - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +seen: Bool -) -> St: +def parse.step.kind.go(long: Bool, dash: Bool, +tok: String, +hh: Here) -> St: match long: case True{}: - parse.take_long(String.drop(tok, 2n), tok, args, up, subs, path, binds, pos, - False{}, seen) + parse.take_long(String.drop(tok, 2n), tok, hh) case False{}: - parse.step.short(dash, tok, args, up, subs, path, binds, pos, seen) + parse.step.short(dash, tok, hh) # a long option, a short option, or a word -def parse.step.kind( - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +seen: Bool -) -> St: - parse.step.kind.go(String.starts_with(tok, "--"), String.starts_with(tok, "-"), tok, - args, up, subs, path, binds, pos, seen) +def parse.step.kind(+tok: String, +hh: Here) -> St: + parse.step.kind.go(String.starts_with(tok, "--"), String.starts_with(tok, "-"), tok, hh) # `help` in command position collects the rest of argv as a path -def parse.step.help( - hit: Bool, - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +seen: Bool -) -> St: +def parse.step.help(hit: Bool, +tok: String, +hh: Here) -> St: match hit: case True{}: - St{Help{}, args, up, subs, path, binds, pos, False{}, seen} + parse.at(Help{}, hh) case False{}: - parse.step.kind(tok, args, up, subs, path, binds, pos, seen) + parse.step.kind(tok, hh) # `--` ends option parsing -def parse.step.end( - end: Bool, - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +seen: Bool -) -> St: +def parse.step.end(end: Bool, +tok: String, +hh: Here) -> St: match end: case True{}: + Here{args, up, subs, path, binds, pos, _r, seen} = hh St{Free{}, args, up, subs, path, binds, pos, True{}, seen} case False{}: - parse.step.help(Bool.and(String.eq(tok, "help"), Bool.not(seen)), tok, args, - up, subs, path, binds, pos, seen) + parse.step.help(Bool.and(String.eq(tok, "help"), Bool.not(here.seen(hh))), tok, hh) # after `--`, every token is a positional -def parse.step.raw( - raw: Bool, - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +seen: Bool -) -> St: +def parse.step.raw(+tok: String, hh: Here) -> St: + Here{+args, +up, +subs, +path, +binds, +pos, raw, +seen} = hh match raw: case True{}: parse.take_pos(tok, args, up, subs, path, binds, pos, True{}) case False{}: - parse.step.end(String.eq(tok, "--"), tok, args, up, subs, path, binds, pos, - seen) + parse.step.end(String.eq(tok, "--"), tok, Here{args, up, subs, path, binds, pos, False{}, seen}) # a pending option value: a flag-shaped token is a missing value -def parse.step.need( - flag: Bool, - +name: String, - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.step.need(flag: Bool, +name: String, +tok: String, +hh: Here) -> St: match flag: case True{}: - parse.dead(NoValue{path, name}, args, up, subs, path, binds, pos, raw, seen) + parse.dead(NoValue{here.path(hh), name}, hh) case False{}: - parse.take_opt_val(name, tok, args, up, subs, path, binds, pos, raw, seen) + parse.take_opt_val(name, tok, hh) # a word after `help`: the subcommand it names, whose own subcommands the # next word is looked up in, or an unexpected word -def parse.step.help_path( - found: Maybe<&2, Sub>, - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.step.help_path(found: Maybe<&2, Sub>, +tok: String, +hh: Here) -> St: match found: case None{}: - parse.dead(Unexpected{path, tok}, args, up, subs, path, binds, pos, raw, seen) + parse.dead(Unexpected{here.path(hh), tok}, hh) case Some{ss}: Sub{_n, _a, _g, next_subs} = ss - St{Help{}, args, up, next_subs, List.append(&2, String, path, [tok]), binds, - pos, raw, seen} + Here{args, up, _s, path, binds, pos, raw, seen} = hh + St{Help{}, args, up, next_subs, List.append(&2, String, path, [tok]), binds, pos, raw, seen} # one token against the walker -def parse.step.mode( - mode: Mode, - +tok: String, - +args: List<&2, Arg>, - +up: List<&2, Level>, - +subs: List<&2, Sub>, - +path: List<&2, String>, - +binds: List<&2, Bind>, - +pos: List<&2, Arg>, - +raw: Bool, - +seen: Bool -) -> St: +def parse.step.mode(mode: Mode, +tok: String, +hh: Here) -> St: match mode: case Dead{e}: - St{Dead{e}, args, up, subs, path, binds, pos, raw, seen} + parse.at(Dead{e}, hh) case Need{name}: - parse.step.need(looks_flag(tok), name, tok, args, up, subs, path, binds, pos, - raw, seen) + parse.step.need(looks_flag(tok), name, tok, hh) case Help{}: - parse.step.help_path(find_sub(subs, tok), tok, args, up, subs, path, binds, pos, raw, - seen) + parse.step.help_path(find_sub(here.subs(hh), tok), tok, hh) case Free{}: - parse.step.raw(raw, tok, args, up, subs, path, binds, pos, seen) + parse.step.raw(tok, hh) # one token def parse.step(+tok: String, st: St) -> St: St{mode, args, up, subs, path, binds, pending, raw, seen} = st - parse.step.mode(mode, tok, args, up, subs, path, binds, pending, raw, seen) + parse.step.mode(mode, tok, Here{args, up, subs, path, binds, pending, raw, seen}) # every token, in order def parse.walk(argv: List<&2, String>, st: St) -> St: diff --git a/src/grow.bend b/src/grow.bend index 7072c0b..0f21fd7 100644 --- a/src/grow.bend +++ b/src/grow.bend @@ -205,7 +205,8 @@ law gw.choice: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_choice(ok, name, val, args, up, subs, path, binds, pos, raw, seen), View{args, up, + gw.Stay(Shake.parse.take_choice(ok, name, val, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.choice(ok, name, val, _args, _up, _subs, _path, _binds, _pos, _raw, _seen): @@ -227,7 +228,8 @@ law gw.opt_val: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_opt_val(name, val, args, up, subs, path, binds, pos, raw, seen), View{args, up, path, binds}) + gw.Stay(Shake.parse.take_opt_val(name, val, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.opt_val(name, val, args, up, subs, path, binds, pos, raw, seen): gw.choice(Shake.allowed(Shake.parse.choices(Shake.by_name(args, name)), val), name, val, args, up, subs, @@ -246,7 +248,8 @@ law gw.flag: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen), View{args, up, + gw.Stay(Shake.parse.take_flag(val, name, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.flag(val, name, _orig, _args, _up, _subs, _path, _binds, _pos, _raw, _seen): @@ -268,7 +271,8 @@ law gw.opt: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_opt(val, name, args, up, subs, path, binds, pos, raw, seen), View{args, up, path, binds}) + gw.Stay(Shake.parse.take_opt(val, name, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.opt(val, name, args, up, subs, path, binds, pos, raw, seen): match val: @@ -310,18 +314,20 @@ law gw.kind: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_arg.kind(kk, name, val, orig, args, up, subs, path, binds, pos, raw, seen), + gw.Stay(Shake.parse.take_arg.kind(kk, name, val, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), View{args, up, path, binds}) def gw.kind(kk, name, val, orig, args, up, subs, path, binds, pos, raw, seen): match kk: case Shake.Flag{}: - gw.once(Shake.bound(binds, name), Shake.parse.take_flag(val, name, orig, args, up, subs, path, binds, - pos, raw, seen), name, path, View{args, up, path, binds}, {==})( + gw.once(Shake.bound(binds, name), + Shake.parse.take_flag(val, name, orig, + Shake.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, View{args, up, path, binds}, {==})( gw.flag(val, name, orig, args, up, subs, path, binds, pos, raw, seen)) case Shake.Opt{}: - gw.once(Shake.bound(binds, name), Shake.parse.take_opt(val, name, args, up, subs, path, binds, pos, - raw, seen), name, path, View{args, up, path, binds}, {==})( + gw.once(Shake.bound(binds, name), + Shake.parse.take_opt(val, name, + Shake.Here{args, up, subs, path, binds, pos, raw, seen}), name, path, View{args, up, path, binds}, {==})( gw.opt(val, name, args, up, subs, path, binds, pos, raw, seen)) case Shake.Many{}: gw.opt(val, name, args, up, subs, path, binds, pos, raw, seen) @@ -343,7 +349,8 @@ law gw.arg: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_arg(found, val, orig, args, up, subs, path, binds, pos, raw, seen), View{args, up, + gw.Stay(Shake.parse.take_arg(found, val, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.arg(found, val, orig, args, up, subs, path, binds, pos, raw, seen): @@ -367,7 +374,7 @@ law gw.lhelp: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_long.help(hit, orig, args, up, subs, path, binds, pos, raw, seen), View{args, up, + gw.Stay(Shake.parse.take_long.help(hit, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), View{args, up, path, binds}) def gw.lhelp(hit, _orig, _args, _up, _subs, _path, _binds, _pos, _raw, _seen): @@ -391,7 +398,7 @@ law gw.found: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_long.found(found, name, val, orig, args, up, subs, path, binds, pos, raw, seen), + gw.Stay(Shake.parse.take_long.found(found, name, val, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), View{args, up, path, binds}) def gw.found(found, name, val, orig, args, up, subs, path, binds, pos, raw, seen): @@ -415,8 +422,8 @@ law gw.named: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_long.named(empty, name, val, orig, args, up, subs, path, binds, pos, raw, - seen), View{args, up, path, binds}) + gw.Stay(Shake.parse.take_long.named(empty, name, val, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.named(empty, name, val, orig, args, up, subs, path, binds, pos, raw, seen): match empty: @@ -437,7 +444,8 @@ law gw.cut: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_long.cut(nv, orig, args, up, subs, path, binds, pos, raw, seen), View{args, up, path, binds}) + gw.Stay(Shake.parse.take_long.cut(nv, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.cut(nv, orig, args, up, subs, path, binds, pos, raw, seen): match nv: @@ -456,7 +464,8 @@ law gw.long: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_long(body, orig, args, up, subs, path, binds, pos, raw, seen), View{args, up, path, binds}) + gw.Stay(Shake.parse.take_long(body, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.long(body, orig, args, up, subs, path, binds, pos, raw, seen): gw.cut(Shake.cut_eq(body), orig, args, up, subs, path, binds, pos, raw, seen) @@ -475,7 +484,7 @@ law gw.apply_mode: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.cluster.apply.mode(mode, cc, rest, orig, args, up, subs, path, binds, pos, raw, seen), + gw.Stay(Shake.cluster.apply.mode(mode, cc, rest, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), View{args, up, path, binds}) def gw.apply_mode(mode, cc, rest, orig, args, up, subs, path, binds, pos, raw, seen): @@ -552,7 +561,7 @@ law gw.sgo: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_short.go(hit, body, orig, args, up, subs, path, binds, pos, raw, seen), + gw.Stay(Shake.parse.take_short.go(hit, body, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), View{args, up, path, binds}) def gw.sgo(hit, body, orig, args, up, subs, path, binds, pos, raw, seen): @@ -574,7 +583,8 @@ law gw.short: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.take_short(body, orig, args, up, subs, path, binds, pos, raw, seen), View{args, up, path, binds}) + gw.Stay(Shake.parse.take_short(body, orig, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.short(body, orig, args, up, subs, path, binds, pos, raw, seen): gw.sgo(Shake.short_help(body, args, seen), body, orig, args, up, subs, path, binds, pos, raw, seen) @@ -670,7 +680,8 @@ law gw.enter_or: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Step(Shake.parse.enter_or(miss, ss, args, up, subs, path, binds, pos, raw, seen), View{args, up, path, binds}) + gw.Step(Shake.parse.enter_or(miss, ss, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.enter_or(miss, ss, args, up, _subs, path, binds, _pos, _raw, _seen): match miss: @@ -691,7 +702,8 @@ law gw.word_go: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Step(Shake.parse.word.go(found, tok, args, up, subs, path, binds, pos, raw, seen), View{args, up, path, binds}) + gw.Step(Shake.parse.word.go(found, tok, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.word_go(found, tok, args, up, subs, path, binds, pos, raw, seen): match found: @@ -711,7 +723,7 @@ law gw.word: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Step(Shake.parse.word(tok, args, up, subs, path, binds, pos, raw, seen), View{args, up, path, binds}) + gw.Step(Shake.parse.word(tok, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), View{args, up, path, binds}) def gw.word(tok, args, up, subs, path, binds, pos, raw, seen): gw.word_go(Shake.find_sub(subs, tok), tok, args, up, subs, path, binds, pos, raw, seen) @@ -727,7 +739,8 @@ law gw.short_go: for +binds: List<&2, Shake.Bind> for +pos: List<&2, Shake.Arg> for +seen: Bool - gw.Step(Shake.parse.step.short.go(alone, tok, args, up, subs, path, binds, pos, seen), View{args, up, path, binds}) + gw.Step(Shake.parse.step.short.go(alone, tok, Shake.Here{args, up, subs, path, binds, pos, False{}, seen}), + View{args, up, path, binds}) def gw.short_go(alone, tok, args, up, subs, path, binds, pos, seen): match alone: @@ -747,7 +760,8 @@ law gw.step_short: for +binds: List<&2, Shake.Bind> for +pos: List<&2, Shake.Arg> for +seen: Bool - gw.Step(Shake.parse.step.short(dash, tok, args, up, subs, path, binds, pos, seen), View{args, up, path, binds}) + gw.Step(Shake.parse.step.short(dash, tok, Shake.Here{args, up, subs, path, binds, pos, False{}, seen}), + View{args, up, path, binds}) def gw.step_short(dash, tok, args, up, subs, path, binds, pos, seen): match dash: @@ -768,7 +782,7 @@ law gw.kind_go: for +binds: List<&2, Shake.Bind> for +pos: List<&2, Shake.Arg> for +seen: Bool - gw.Step(Shake.parse.step.kind.go(long, dash, tok, args, up, subs, path, binds, pos, seen), + gw.Step(Shake.parse.step.kind.go(long, dash, tok, Shake.Here{args, up, subs, path, binds, pos, False{}, seen}), View{args, up, path, binds}) def gw.kind_go(long, dash, tok, args, up, subs, path, binds, pos, seen): @@ -789,7 +803,8 @@ law gw.help: for +binds: List<&2, Shake.Bind> for +pos: List<&2, Shake.Arg> for +seen: Bool - gw.Step(Shake.parse.step.help(hit, tok, args, up, subs, path, binds, pos, seen), View{args, up, path, binds}) + gw.Step(Shake.parse.step.help(hit, tok, Shake.Here{args, up, subs, path, binds, pos, False{}, seen}), + View{args, up, path, binds}) def gw.help(hit, tok, args, up, subs, path, binds, pos, seen): match hit: @@ -810,7 +825,8 @@ law gw.end: for +binds: List<&2, Shake.Bind> for +pos: List<&2, Shake.Arg> for +seen: Bool - gw.Step(Shake.parse.step.end(end, tok, args, up, subs, path, binds, pos, seen), View{args, up, path, binds}) + gw.Step(Shake.parse.step.end(end, tok, Shake.Here{args, up, subs, path, binds, pos, False{}, seen}), + View{args, up, path, binds}) def gw.end(end, tok, args, up, subs, path, binds, pos, seen): match end: @@ -830,7 +846,8 @@ law gw.raw: for +binds: List<&2, Shake.Bind> for +pos: List<&2, Shake.Arg> for +seen: Bool - gw.Step(Shake.parse.step.raw(raw, tok, args, up, subs, path, binds, pos, seen), View{args, up, path, binds}) + gw.Step(Shake.parse.step.raw(tok, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), + View{args, up, path, binds}) def gw.raw(raw, tok, args, up, subs, path, binds, pos, seen): match raw: @@ -852,7 +869,7 @@ law gw.need: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stay(Shake.parse.step.need(flag, name, tok, args, up, subs, path, binds, pos, raw, seen), + gw.Stay(Shake.parse.step.need(flag, name, tok, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), View{args, up, path, binds}) def gw.need(flag, name, tok, args, up, subs, path, binds, pos, raw, seen): @@ -874,7 +891,7 @@ law gw.help_path: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Stuck(Shake.parse.step.help_path(found, tok, args, up, subs, path, binds, pos, raw, seen)) + gw.Stuck(Shake.parse.step.help_path(found, tok, Shake.Here{args, up, subs, path, binds, pos, raw, seen})) def gw.help_path(found, _tok, _args, _up, _subs, _path, _binds, _pos, _raw, _seen): match found: @@ -897,7 +914,7 @@ law gw.mode: for +pos: List<&2, Shake.Arg> for +raw: Bool for +seen: Bool - gw.Step(Shake.parse.step.mode(mode, tok, args, up, subs, path, binds, pos, raw, seen), + gw.Step(Shake.parse.step.mode(mode, tok, Shake.Here{args, up, subs, path, binds, pos, raw, seen}), View{args, up, path, binds}) def gw.mode(mode, tok, args, up, subs, path, binds, pos, raw, seen): @@ -1171,7 +1188,7 @@ def gw.stuck_mode.ty( +raw: Bool, +seen: Bool ) -> Type: - gw.Stuck(Shake.parse.step.mode(mode, tok, args, up, subs, path, binds, pos, raw, seen)) + gw.Stuck(Shake.parse.step.mode(mode, tok, Shake.Here{args, up, subs, path, binds, pos, raw, seen})) # a mode that cannot finish as a success stays so law gw.stuck_mode: diff --git a/src/walk.bend b/src/walk.bend index 9e37f76..ff341c9 100644 --- a/src/walk.bend +++ b/src/walk.bend @@ -250,19 +250,21 @@ law wk.word_step: def wk.word_step(tok, args, up, subs, path, bs, pos, seen, h_dd, h_help, h_dash, h_sub): e1 = Equal.sym(Bool, String.eq(tok, "--"), False{}, h_dd) - %e1 : {Shake.parse.step.end(_, tok, args, up, subs, path, bs, pos, seen) + %e1 : {Shake.parse.step.end(_, tok, Shake.Here{args, up, subs, path, bs, pos, False{}, seen}) == Shake.parse.take_pos(tok, args, up, subs, path, bs, pos, False{}) : Shake.St} e2 = Equal.sym(Bool, String.eq(tok, "help"), False{}, h_help) - %e2 : {Shake.parse.step.help(Bool.and(_, Bool.not(seen)), tok, args, up, subs, path, bs, pos, seen) + %e2 : {Shake.parse.step.help(Bool.and(_, Bool.not(seen)), tok, + Shake.Here{args, up, subs, path, bs, pos, False{}, seen}) == Shake.parse.take_pos(tok, args, up, subs, path, bs, pos, False{}) : Shake.St} e3 = Equal.sym(Bool, String.starts_with(tok, "--"), False{}, wk.dash(tok, h_dash)) - %e3 : {Shake.parse.step.kind.go(_, String.starts_with(tok, "-"), tok, args, up, subs, path, bs, pos, seen) + %e3 : {Shake.parse.step.kind.go(_, String.starts_with(tok, "-"), tok, + Shake.Here{args, up, subs, path, bs, pos, False{}, seen}) == Shake.parse.take_pos(tok, args, up, subs, path, bs, pos, False{}) : Shake.St} e4 = Equal.sym(Bool, String.starts_with(tok, "-"), False{}, h_dash) - %e4 : {Shake.parse.step.kind.go(False{}, _, tok, args, up, subs, path, bs, pos, seen) + %e4 : {Shake.parse.step.kind.go(False{}, _, tok, Shake.Here{args, up, subs, path, bs, pos, False{}, seen}) == Shake.parse.take_pos(tok, args, up, subs, path, bs, pos, False{}) : Shake.St} e5 = Equal.sym(Maybe<&2, Shake.Sub>, Shake.find_sub(subs, tok), None{}, h_sub) - %e5 : {Shake.parse.word.go(_, tok, args, up, subs, path, bs, pos, False{}, seen) + %e5 : {Shake.parse.word.go(_, tok, Shake.Here{args, up, subs, path, bs, pos, False{}, seen}) == Shake.parse.take_pos(tok, args, up, subs, path, bs, pos, False{}) : Shake.St} {==}