Skip to content

Commit 7d591d3

Browse files
committed
WIP generator changes
1 parent 9ea45ed commit 7d591d3

12 files changed

Lines changed: 1349 additions & 625 deletions

File tree

Strata/DDM/Integration/Lean/BoolConv.lean

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,28 @@ public section
1111
namespace Strata
1212

1313
/-- Convert Init.Bool inductive to OperationF -/
14-
def Bool.toAst {α} [Inhabited α] (v : Ann Bool α) : OperationF α :=
15-
if v.val then
16-
⟨v.ann, q`Init.boolTrue, #[]
14+
def OperationF.ofBool {α} (ann : α) (b : Bool) : OperationF α :=
15+
if b then
16+
{ ann := ann, name := q`Init.boolTrue, args := #[] }
1717
else
18-
⟨v.ann, q`Init.boolFalse, #[]
18+
{ ann := ann, name := q`Init.boolFalse, args := #[] }
1919

2020
/-- Convert OperationF to Init.Bool -/
21-
def Bool.ofAst {α} [Inhabited α] [Repr α] (op : OperationF α) : OfAstM (Ann Bool α) :=
22-
match op.name with
23-
| q`Init.boolTrue =>
24-
if op.args.size = 0 then
25-
pure ⟨op.ann, true⟩
26-
else
27-
.error s!"boolTrue expects 0 arguments, got {op.args.size}"
28-
| q`Init.boolFalse =>
29-
if op.args.size = 0 then
30-
pure ⟨op.ann, false⟩
31-
else
32-
.error s!"boolFalse expects 0 arguments, got {op.args.size}"
33-
| _ =>
34-
.error s!"Unknown Bool operator: {op.name}"
21+
def Bool.ofAst {α} [Inhabited α] [Repr α] (arg : ArgF α) : OfAstM Bool := do
22+
match arg with
23+
| .op op =>
24+
match op.name with
25+
| q`Init.boolTrue =>
26+
if op.args.size ≠ 0 then
27+
.error s!"boolTrue expects 0 arguments, got {op.args.size}"
28+
pure true
29+
| q`Init.boolFalse =>
30+
if op.args.size ≠ 0 then
31+
.error s!"boolFalse expects 0 arguments, got {op.args.size}"
32+
pure false
33+
| _ =>
34+
.error s!"Unknown Bool operator: {op.name}"
35+
| _ => .throwExpected "boolean" arg
3536

3637
end Strata
3738
end

0 commit comments

Comments
 (0)