Leonardo de Moura
6a0208630e
feat: add sanity checking at macro_rules
2020-01-25 20:31:58 -08:00
Leonardo de Moura
f5630ae054
chore: remove let_core
2020-01-25 20:17:25 -08:00
Leonardo de Moura
1512ccfdc8
chore: reacticate where elaboration
2020-01-25 20:11:42 -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
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
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
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
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
b708407b7b
chore: implement Quotation.lean using let_core, disable let syntax
2020-01-25 15:34:24 -08:00
Leonardo de Moura
993ae96fb7
chore: elaborate let_core
2020-01-25 15:21:47 -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
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
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
88fe0de284
fix: default LEAN_PATH for installed Lean
2020-01-25 15:58:06 +01:00
Sebastian Ullrich
5c0fa84af5
feat: barely implement do elaboration
2020-01-25 15:57:41 +01:00
Sebastian Ullrich
02c773bc70
refactor: further Quotation cleanup
2020-01-25 13:47:27 +01:00
Sebastian Ullrich
093518725c
refactor: minor cleanups for standalone expander
2020-01-25 11:58:29 +01:00
Leonardo de Moura
aa045f3b07
feat: safer mkCIdentFrom
...
cc @Kha
2020-01-24 17:23:21 -08:00
Leonardo de Moura
364bb7bdf7
fix: proper Name literals
...
cc @kha
2020-01-24 12:38:15 -08:00
Leonardo de Moura
35179809a2
feat: hide macro scopes encoding when displaying errors
2020-01-23 15:33:02 -08:00
Leonardo de Moura
060a68d73f
feat: remove addMacroScope approximation
2020-01-23 14:59:31 -08:00
Leonardo de Moura
ed6cb007d0
refactor: ExtractMacroScopesResult => MacroScopesView, add MacroScopesView.review
2020-01-23 14:11:32 -08:00
Leonardo de Moura
c309f1dccd
chore: remove unnecessary field
2020-01-23 13:05:27 -08:00
Leonardo de Moura
b47caaa0a5
refactor: notation and macro commands are now just macros
2020-01-23 13:04:21 -08:00
Leonardo de Moura
9359a6569a
feat: add [builtinMacro]
2020-01-23 12:54:04 -08:00
Leonardo de Moura
954c69de35
feat: use macroscopes for creating fresh kinds
2020-01-23 12:38:31 -08:00
Leonardo de Moura
d99ef11447
fix: nested addMacroScope
2020-01-23 12:36:37 -08:00
Leonardo de Moura
e681bd71d9
feat: simplify MacroM
2020-01-23 12:22:33 -08:00
Leonardo de Moura
0228f9c9b7
chore: remove addMacroScopeExt
2020-01-23 12:08:20 -08:00
Leonardo de Moura
6fdcb1c192
chore: prepare to remove addMacroScopeExt
2020-01-23 12:02:45 -08:00
Leonardo de Moura
4ef8aa347a
feat: missing case
2020-01-23 11:46:29 -08:00
Leonardo de Moura
fab256d4cc
feat: improve macroscope encoding
2020-01-23 11:33:35 -08:00
Leonardo de Moura
87d002bb43
feat: extend MacroM
...
It now has access to `mainModule` and a name generator.
2020-01-23 09:48:37 -08:00
Leonardo de Moura
98ee6e9734
refactor: move NameGenerator to LeanInit
2020-01-23 08:49:58 -08:00
Leonardo de Moura
67535441ad
fix: macroTail issue
...
cc @Kha
2020-01-22 20:14:09 -08:00
Leonardo de Moura
764b854742
fix: bug at longestMatchStep
...
@Kha I found the bug by accident when I was playing with the
bigop.lean
2020-01-22 17:31:54 -08:00
Leonardo de Moura
3f24b31286
chore: remove leftover
2020-01-22 16:50:05 -08:00
Leonardo de Moura
1ff7950a77
feat: use truncateTrailing at error messages
2020-01-22 16:19:07 -08:00