Skip to content

Commit

Permalink
remove begin ... end syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Aug 17, 2023
1 parent 1471049 commit e67b6aa
Show file tree
Hide file tree
Showing 36 changed files with 125 additions and 134 deletions.
5 changes: 4 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
remove `begin end` syntax
top level env has checking -- for top level `Compose`

- begin-type.error.i
- begin-type-nested.error.i

# books

Expand Down
32 changes: 0 additions & 32 deletions src/lang/stmts/Begin.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/lang/stmts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./Begin"
export * from "./Check"
export * from "./Claim"
export * from "./Compose"
Expand Down
2 changes: 1 addition & 1 deletion src/lang/syntax/grammars/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const preserved = [
...["define", "claim"],
...["type", "node", "rule"],
...["begin", "check"],
...["check"],
...["import", "require"],
...["end"],
]
Expand Down
1 change: 0 additions & 1 deletion src/lang/syntax/grammars/stmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const stmt = {
{ output: "words" },
'"end"',
],
"stmt:begin": ['"begin"', { words: "words" }, '"end"'],
"stmt:check": [
'"check"',
{ input: "words" },
Expand Down
2 changes: 0 additions & 2 deletions src/lang/syntax/matchers/stmt_matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export function stmt_matcher(tree: pt.Tree): Stmt {
matchers.words_matcher(output),
span,
),
"stmt:begin": ({ words }, { span }) =>
new Stmts.Begin(matchers.words_matcher(words), span),
"stmt:check": ({ input, output, words }, { span }) =>
new Stmts.Check(
matchers.words_matcher(input),
Expand Down
2 changes: 1 addition & 1 deletion tests/builtin/connect-args.error.i
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Trivial -- Type end
node sole -- Trivial :value! end

begin sole connect end
sole connect
8 changes: 5 additions & 3 deletions tests/builtin/connect-args.error.i.err
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
1 |type Trivial -- Type end
2 |node sole -- Trivial :value! end
3 |
4 |begin sole connect end
4 |sole connect
5 |

[Begin.execute] I fail to begin.
[Compose.execute] I fail to compose word.

word: connect

1 |type Trivial -- Type end
2 |node sole -- Trivial :value! end
3 |
4 |begin sole connect end
4 |sole connect
5 |
2 changes: 1 addition & 1 deletion tests/builtin/inspect-args.error.i
Original file line number Diff line number Diff line change
@@ -1 +1 @@
begin inspect end
inspect
8 changes: 5 additions & 3 deletions tests/builtin/inspect-args.error.i.err
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

word: inspect

1 |begin inspect end
1 |inspect
2 |

[Begin.execute] I fail to begin.
[Compose.execute] I fail to compose word.

1 |begin inspect end
word: inspect

1 |inspect
2 |
2 changes: 1 addition & 1 deletion tests/builtin/rot-args.error.i
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Trivial -- Type end
node sole -- Trivial :value! end

begin sole sole rot end
sole sole rot
10 changes: 7 additions & 3 deletions tests/builtin/rot-args.error.i.err
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
1 |type Trivial -- Type end
2 |node sole -- Trivial :value! end
3 |
4 |begin sole sole rot end
4 |sole sole rot
5 |

[Begin.execute] I fail to begin.
[Compose.execute] I fail to compose word.

word: rot

1 |type Trivial -- Type end
2 |node sole -- Trivial :value! end
3 |
4 |begin sole sole rot end
4 |sole sole rot
5 |
12 changes: 5 additions & 7 deletions tests/builtin/run-only-top-port.i
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
require "../datatype/Nat.i"

begin
one one add
one one add
run inspect
swap inspect
run inspect
end
one one add
one one add
run inspect
swap inspect
run inspect
2 changes: 1 addition & 1 deletion tests/builtin/swap-args.error.i
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Trivial -- Type end
node sole -- Trivial :value! end

begin sole swap end
sole swap
10 changes: 7 additions & 3 deletions tests/builtin/swap-args.error.i.err
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
1 |type Trivial -- Type end
2 |node sole -- Trivial :value! end
3 |
4 |begin sole swap end
4 |sole swap
5 |

[Begin.execute] I fail to begin.
[Compose.execute] I fail to compose word.

word: swap

1 |type Trivial -- Type end
2 |node sole -- Trivial :value! end
3 |
4 |begin sole swap end
4 |sole swap
5 |
2 changes: 1 addition & 1 deletion tests/checking/begin-sign.error.i
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Trivial -- Type end
node sole -- Trivial :value! end

begin sole sole connect end
sole sole connect
8 changes: 5 additions & 3 deletions tests/checking/begin-sign.error.i.err
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
1 |type Trivial -- Type end
2 |node sole -- Trivial :value! end
3 |
4 |begin sole sole connect end
4 |sole sole connect
5 |

[Begin.execute] I fail to begin.
[Compose.execute] I fail to compose word.

word: connect

1 |type Trivial -- Type end
2 |node sole -- Trivial :value! end
3 |
4 |begin sole sole connect end
4 |sole sole connect
5 |
4 changes: 3 additions & 1 deletion tests/checking/begin-type-nested.error.i
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ node cons
'A List :value!
end

begin sole sole cons end
sole sole cons

TODO
24 changes: 14 additions & 10 deletions tests/checking/begin-type-nested.error.i.err
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
[unifyTypes] I fail to unify types.
[lookupDefinitionOrFail] I meet undefined name.

left: Trivial
right: Trivial List
name: TODO

[compose] I fail compose word.

word: cons
word: TODO

15 | 'A List :value!
16 |end
17 |
18 |begin sole sole cons end
18 |sole sole cons
19 |
20 |TODO
21 |

[Begin.execute] I fail to begin.
[Compose.execute] I fail to compose word.

word: TODO

14 | --------
15 | 'A List :value!
16 |end
17 |
18 |begin sole sole cons end
18 |sole sole cons
19 |
20 |TODO
21 |
4 changes: 3 additions & 1 deletion tests/checking/begin-type.error.i
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ node add1 Nat :prev -- Nat :value! end
type Trivial -- Type end
node sole -- Trivial :value! end

begin sole add1 end
sole add1

TODO
22 changes: 12 additions & 10 deletions tests/checking/begin-type.error.i.err
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
[unifyTypes] I fail to unify types.
[lookupDefinitionOrFail] I meet undefined name.

left: Trivial
right: Nat
name: TODO

[compose] I fail compose word.

word: add1
word: TODO

5 |type Trivial -- Type end
6 |node sole -- Trivial :value! end
7 |
8 |begin sole add1 end
8 |sole add1
9 |
10 |TODO
11 |

[Begin.execute] I fail to begin.
[Compose.execute] I fail to compose word.

word: TODO

4 |
5 |type Trivial -- Type end
6 |node sole -- Trivial :value! end
7 |
8 |begin sole add1 end
8 |sole add1
9 |
10 |TODO
11 |
2 changes: 1 addition & 1 deletion tests/checking/rearrange-duplicated-name.error.i
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ node cons
'A List :value!
end

begin sole (:head:tail cons :tail:head) end
sole (:head:tail cons :tail:head)
11 changes: 7 additions & 4 deletions tests/checking/rearrange-duplicated-name.error.i.err
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
15 | 'A List :value!
16 |end
17 |
18 |begin sole (:head:tail cons :tail:head) end
18 |sole (:head:tail cons :tail:head)
19 |

[Begin.execute] I fail to begin.
[Compose.execute] I fail to compose word.

word: (:head:tail cons :tail:head)

14 | --------
15 | 'A List :value!
16 |end
17 |
18 |begin sole (:head:tail cons :tail:head) end
18 |sole (:head:tail cons :tail:head)
19 |
2 changes: 1 addition & 1 deletion tests/checking/rearrange-undefined-name.error.i
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ node cons
'A List :value!
end

begin sole (:hi cons) end
sole (:hi cons)
11 changes: 7 additions & 4 deletions tests/checking/rearrange-undefined-name.error.i.err
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
15 | 'A List :value!
16 |end
17 |
18 |begin sole (:hi cons) end
18 |sole (:hi cons)
19 |

[Begin.execute] I fail to begin.
[Compose.execute] I fail to compose word.

word: (:hi cons)

14 | --------
15 | 'A List :value!
16 |end
17 |
18 |begin sole (:hi cons) end
18 |sole (:hi cons)
19 |
2 changes: 1 addition & 1 deletion tests/checking/type-term-args-not-type.error.i
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node sole -- Trivial :value! end

type List Type -- Type end

begin sole List end
sole List
9 changes: 5 additions & 4 deletions tests/checking/type-term-args-not-type.error.i.err
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
3 |
4 |type List Type -- Type end
5 |
6 |begin sole List end
6 |sole List
7 |

[Begin.execute] I fail to begin.
[Compose.execute] I fail to compose word.

word: List

2 |node sole -- Trivial :value! end
3 |
4 |type List Type -- Type end
5 |
6 |begin sole List end
6 |sole List
7 |
Loading

0 comments on commit e67b6aa

Please sign in to comment.