Commit graph

29801 commits

Author SHA1 Message Date
Leonardo de Moura
f0f522a6d6 chore: prepare to rename old coe primitives 2020-01-28 08:18:56 -08:00
Leonardo de Moura
a272670ead test: new instances 2020-01-27 21:23:14 -08:00
Leonardo de Moura
9b6dfa71a2 test: new Coe prototype 2020-01-27 20:33:10 -08:00
Sebastian Ullrich
244382f49c chore: reintroduce accidentally dropped withMacroExpansion 2020-01-27 16:43:18 +01:00
Sebastian Ullrich
88b09315f1 chore: better error message on missing import
The macOS CI build rarely, randomly fails with a "failed to lock file" message.
This commit will not fix this error, but at least should make it clearer whether
the file actually cannot be locked or is just missing.

/cc @leodemoura
2020-01-27 13:09:01 +01:00
Sebastian Ullrich
9065ce55a8 chore: ignore test output files 2020-01-27 13:08:57 +01:00
Sebastian Ullrich
c805eb87e6 refactor: elabAnoymousCtor: align more closely to the paper 2020-01-27 10:35:16 +01:00
Leonardo de Moura
254d29b4b7 chore: update stage0 2020-01-26 15:15:20 -08:00
Leonardo de Moura
145bd50903 feat: disallow patterns with choice nodes
@Kha Patterns with nested "choice" nodes produce counterintuitive
behavior, and hard to understand errors. They only work when we have
the exact same overloads at macro definition and application time.

Here is a funky example
```
syntax [myAdd] term "++":65 term:65 : term    -- overloads "++"
/- The following `macro_rules` manages to eliminate "choice" node by using the
   explicitly provided node kind. -/
macro_rules [myAdd] `($a ++ $b) => `($a + $b)

check (1:Nat) ++ 2 -- works as expected

syntax "FOO!" term : term

/- Before this commit, the following pattern was accepted,
   and it contained a "choice" node for `++`. It is a `myAdd` or
   `HasAppend.append`.

   Now, this kind of pattern is rejected since it contains a nested
   "choice" -/
macro_rules `(FOO! $a ++ $b) => `($a ++ $b)

/- Before this commit, the following command worked because
   it contained a "choice" node similar to the one at macro definition
   time. -/
check FOO! [1, 2] ++ [2, 3]

-- Now, we have 3 overloads for "++".
syntax [myAppend] term "++":65 term:65 : term

-- The `macro_rules` fails here.
```

This commit fixes this weird behavior by disallowing "choice" nodes in
patterns.
2020-01-26 15:13:14 -08:00
Leonardo de Moura
4e580e78bc chore: update stage0 2020-01-26 15:13:14 -08:00
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