Commit graph

26741 commits

Author SHA1 Message Date
Leonardo de Moura
8525584a78 refactor: naming consistency ensure List and Array have similar find* methods
`find?`     -> takes predicate
`findSome?` -> takes a function (A -> Option B)
2020-01-26 15:13:05 -08:00
Leonardo de Moura
ac5eaa4d7d test: overload builtin notation 2020-01-26 14:00:41 -08:00
Leonardo de Moura
5ff63c2bc6 choice: better error message 2020-01-26 13:58:51 -08:00
Leonardo de Moura
cde1399a01 test: overloaded syntax 2020-01-26 13:57:13 -08:00
Leonardo de Moura
17d5453827 fix: elabTerm must be part of observing 2020-01-26 13:55:21 -08:00
Leonardo de Moura
7133d3fc84 feat: handle explicit node kinds in macro_rules, and handle choice kind 2020-01-26 09:39:46 -08:00
Leonardo de Moura
6a1712717f chore: update stage0 2020-01-26 08:43:43 -08:00
Leonardo de Moura
02d31fb619 feat: allow user to specify intended syntax node kind at macro_rules 2020-01-26 08:43:05 -08:00
Leonardo de Moura
e52c4291cc feat: allow macro_rules block with different syntax node kinds 2020-01-26 08:39:40 -08:00
Leonardo de Moura
6a0208630e feat: add sanity checking at macro_rules 2020-01-25 20:31:58 -08:00
Leonardo de Moura
43df63e594 chore: remove unnecessary |s from test 2020-01-25 20:24:22 -08:00
Leonardo de Moura
b0bcc1c2bb chore: update stage0 2020-01-25 20:18:03 -08:00
Leonardo de Moura
f5630ae054 chore: remove let_core 2020-01-25 20:17:25 -08:00
Leonardo de Moura
d0d3e24975 chore: fix tests 2020-01-25 20:14:50 -08:00
Leonardo de Moura
1512ccfdc8 chore: reacticate where elaboration 2020-01-25 20:11:42 -08:00
Leonardo de Moura
ba16094e63 chore: update stage0 2020-01-25 20:01:01 -08:00
Leonardo de Moura
74bac15c6f chore: make sure letDecl is a node
This is useful when defining notation such as `where`.
Moreover, it allows us to write `$d:letDecl`, but `$d` never matches
a `letDecl`
2020-01-25 19:56:53 -08:00
Leonardo de Moura
5b8e713150 chore: minor 2020-01-25 19:35:18 -08:00
Leonardo de Moura
901fcddf89 chore: first | is now optional at macro_rules
cc @Kha
2020-01-25 19:34:44 -08:00
Leonardo de Moura
9f816277fc feat: make sure letSimpleDecl and letPatDecl have the same #args 2020-01-25 19:08:16 -08:00
Leonardo de Moura
051fd530e0 chore: handle new let at toPreterm 2020-01-25 18:33:36 -08:00
Leonardo de Moura
ca690a5571 chore: re-enable let elaborator 2020-01-25 18:24:03 -08:00
Leonardo de Moura
32b36f0ea3 feat: update macro_rules 2020-01-25 18:19:16 -08:00
Leonardo de Moura
c2d2fd98ba chore: update stage0 2020-01-25 18:15:11 -08:00
Leonardo de Moura
71ba6205c3 feat: improve matchAlt syntax 2020-01-25 18:00:30 -08:00
Leonardo de Moura
ca8d6028a1 chore: simplify let decl again 2020-01-25 16:54:26 -08:00
Leonardo de Moura
3759cb2b81 chore: update stage0 2020-01-25 16:42:54 -08:00
Leonardo de Moura
110191abc8 fix: let syntax 2020-01-25 16:41:29 -08:00
Leonardo de Moura
19e4c30542 feat: elaborate new let decl
We can now write
```lean
syntax "case!" ident ":" term "with" term "," term : term
macro_rules
| `(case! $h : $c with $t, $e) => `(let $h := $c; cond $h $t $e)
```

Before the series of commits to change `let` syntax, the
quasiquotation `(let $h := $c; cond $h $t $e)
produced the weird error message "`;` expected" at ":=".
The problem was that $h was matching the now deleted "nonterminal"
```lean
def letIdDecl         := parser! try (letIdLhs >> " := ") >> termParser
```
This was not a bug, but a side-effect on how the `let` syntax was
declared.

cc @kha
2020-01-25 16:32:21 -08:00
Leonardo de Moura
dcf0ae2a33 chore: update stage0 2020-01-25 16:23:39 -08:00
Leonardo de Moura
eb8e7b9f3d feat: add new let syntax
It avoids hidden nonterminals, and store the equation case as a
separate rule. It would be great if we could have 3 independent rules,
but this is not possible because `longestMatch` would return a choice
for terms as simple as `let x := v; ...` The problem is that it is
both a `letSimpleDecl` and a `letPatDecl`. We resolve the ambiguity at
the parsing level using `<|>`.

cc @Kha
2020-01-25 16:15:30 -08:00
Leonardo de Moura
31f8b281c2 chore: update stage0
We are now ready to change `let` syntax
2020-01-25 15:38:49 -08:00
Leonardo de Moura
b708407b7b chore: implement Quotation.lean using let_core, disable let syntax 2020-01-25 15:34:24 -08:00
Leonardo de Moura
618d0d0ce3 chore: update stage0 2020-01-25 15:25:22 -08:00
Leonardo de Moura
993ae96fb7 chore: elaborate let_core 2020-01-25 15:21:47 -08:00
Leonardo de Moura
2ae231cc65 chore: update stage0 2020-01-25 15:15:05 -08:00
Leonardo de Moura
5796eba368 chore: add elabLetDeclAux 2020-01-25 15:14:28 -08:00
Leonardo de Moura
58833e6f79 chore: add let_core
We want to change the representation of `let` terms.
`let_core` is a temporary syntax for helping us with the translation.
2020-01-25 15:08:36 -08:00
Leonardo de Moura
bdb9f4c86e feat: allow raw identifiers to be used where terms are expected
@Kha this commit fix another example of weird error message I have
experienced in the last few days.

The macro
```lean
syntax "case!" ident ":" term "with" term "," term : term
macro_rules
| `(case! $h : $cond with $t, $e) =>
  `((fun $h => cond $h $t $e) $cond)
```
is accepted, but as in `fun` binders, we get a weird error when
trying to elaborate an instance of the macro.
Example:
```lean
check case! h : 0 == 0 with h, not h
```
2020-01-25 14:55:32 -08:00
Leonardo de Moura
0d0f2f7c96 chore: update stage0 2020-01-25 14:55:32 -08:00
Leonardo de Moura
7b6caba457 feat: add `ident as a valid elaboration kind 2020-01-25 14:55:32 -08:00
Leonardo de Moura
6d5de9f965 feat: handle raw identifiers as binders in fun
@Kha I am adding this kind of feature to improve the user experience.
For example, the macro
```
syntax "[" ident "↦" term "]" : term
macro_rules
| `([$x ↦ $v]) => `(fun $x => $v)
```
is accepted and looks perfectly reasonable.
However, before this commit, we would get a nasty error when
elaborating
```lean
check [x ↦ x + 1]
```
2020-01-25 14:55:21 -08:00
Sebastian Ullrich
1bf63f18ec chore: update stage0 2020-01-25 16:42:16 +01:00
Sebastian Ullrich
2509b3913a Revert "feat: add std streams"
This reverts commit 7575a32035.
2020-01-25 16:32:06 +01:00
Sebastian Ullrich
0be2424910 Revert "feat: override standard streams"
This reverts commit bd87ea5d5e.
2020-01-25 16:32:06 +01:00
Sebastian Ullrich
b760692a26 Revert "fix: thread local storage of std streams"
This reverts commit 961861ceab.
2020-01-25 16:32:06 +01:00
Sebastian Ullrich
a4858bf9f9 Revert "feat: MonadIO now extends MonadExcept IO.Error"
This reverts commit c0a7495495.
2020-01-25 16:32:06 +01:00
Sebastian Ullrich
58313a050a Revert "fix: #eval redirection of stdout"
This reverts commit 123577126c.
2020-01-25 16:32:06 +01:00
Sebastian Ullrich
ad29568051 Revert "fix: redirect"
This reverts commit addbb8dd67.
2020-01-25 16:32:06 +01:00
Sebastian Ullrich
e82add884f Revert "fix: test files"
This reverts commit 95f951bdf2.
2020-01-25 16:32:06 +01:00