Commit graph

14244 commits

Author SHA1 Message Date
Leonardo de Moura
17d4117637 chore: remove temporary hacks 2020-09-19 14:21:38 -07:00
Leonardo de Moura
25b40b4b89 chore: disable macro 2020-09-19 14:15:24 -07:00
Leonardo de Moura
71de0c8eb9 chore: rename category syntax to stx
Reason: `syntax` is a keywork. So, we can't write `macro "boo" x:syntax`
2020-09-19 14:11:35 -07:00
Leonardo de Moura
11e65fba2a refactor: factor out macros from mutual elaborator 2020-09-19 13:10:10 -07:00
Leonardo de Moura
3e9b2a0b08 feat: add expandMacro? and expandMacros methods to MacroM 2020-09-19 13:02:27 -07:00
Leonardo de Moura
065a845bfd chore: factor out nested macro at structInst elaborator
@Kha The new macro is another example where it would be super nice to
have better support for `optional` at `match_syntax`.
2020-09-19 11:56:20 -07:00
Leonardo de Moura
dc928d7b05 chore: cleanup do elaborator
Use the fact the macros are executed before elaboration functions.

cc @Kha
2020-09-19 11:49:47 -07:00
Leonardo de Moura
caa624c936 chore: cleanup 2020-09-19 09:24:50 -07:00
Leonardo de Moura
052e67d1af feat: rewrite tactic 2020-09-18 16:13:14 -07:00
Leonardo de Moura
f7bd174bb8 chore: improve error message 2020-09-18 15:23:28 -07:00
Leonardo de Moura
43bc429abf fix: typo 2020-09-18 15:18:20 -07:00
Leonardo de Moura
839f1e1ec8 feat: add elabTermWithHoles 2020-09-18 14:46:04 -07:00
Sebastian Ullrich
68568e78d3 feat: formatter: use hard space after opening structure instance brace 2020-09-18 13:15:40 -07:00
Sebastian Ullrich
519eda2459 feat: formatter: interpret checkWsBefore as soft space 2020-09-18 13:15:40 -07:00
Sebastian Ullrich
95007171a8 feat: formatter: group+indent binders and structure instance fields 2020-09-18 13:15:40 -07:00
Sebastian Ullrich
97a2198fe0 feat: change default indent width from 4 to 2 spaces 2020-09-18 13:15:40 -07:00
Sebastian Ullrich
ec3682ce15 feat: formatter: automatically group+indent syntax categories 2020-09-18 13:15:40 -07:00
Sebastian Ullrich
ac6c2b7a8e feat: formatter: interpret space after token as soft space 2020-09-18 13:15:40 -07:00
Leonardo de Moura
5a24cb5ef7 feat: add hygienicIntro option
@Kha `hygienicIntro` is true by default. `hygienicIntro == false` is
the Lean3 behavior. If we find `hygienicIntro` too inconvenient in
practice, we set the default to false.
2020-09-18 13:02:38 -07:00
Leonardo de Moura
12aabcb731 feat: add introNP and intro1P
Versions of `introN` and `intro1` that preserve the binder name.
They are used to implement the idiom: "revert", do something, re-"intro"-tuce
Before this commit `introNP mvarId n` was `intro1 mvarId n [] false`.
2020-09-18 12:35:25 -07:00
Leonardo de Moura
02e6f019c4 refactor: move nextMacroScope to Core.State
@Kha We now can create scoped user-facing names at `CoreM` and `MetaM`
methods.
2020-09-18 12:00:24 -07:00
Leonardo de Moura
22dc784c3e chore: cleanup 2020-09-18 11:37:51 -07:00
Leonardo de Moura
0e8f8117a1 refactor: simpler mechanism for never backtracking traces
We do backtrack messages but not traces.

cc @Kha
2020-09-18 10:31:42 -07:00
Leonardo de Moura
a28679358e refactor: remove MonadError 2020-09-18 09:58:13 -07:00
Leonardo de Moura
0d295560c3 feat: add replaceLocalDecl
It preserves the location of the local declaration.
@Kha This tactic is going to be used to fix another hygiene related bug in
Lean3 :)
Here is small repro for the problem.
```
example (m n k : ℕ) (h : 0 + n = m) (h : k = m) : ...  :=
begin
  -- Here `h : k = m` is accessible.
  rw [nat.zero_add] at *
  -- `h : k = m` is not accessible anymore, and it is a name for
  -- the simplified `h : n = m` which was inaccessible before.
end
```
2020-09-17 19:27:48 -07:00
Leonardo de Moura
36bfe7b266 feat: add assertAfter tactic 2020-09-17 19:25:53 -07:00
Leonardo de Moura
7b6d06df0d fix: remove bad instances
They are unnecessary, and were producing a very big search space in a
few examples.
2020-09-17 17:31:09 -07:00
Leonardo de Moura
9c8f57f322 fix: preserve info messages from candidates that failed to be elaborated
@Kha Not sure whether we should have an option for supressing this
information or not.
We need this information for diagnosing problems. For example, I was trying to
understand why the elaborator was looping. I suspected it was the
TC module, but I was not getting any trace messages since the symbol
was overloaded, and the case that did not work was the expensive one :(
2020-09-17 17:08:14 -07:00
Leonardo de Moura
59bf4defc6 fix: default value 2020-09-17 15:58:29 -07:00
Leonardo de Moura
3dbe2076b9 refactor: Target&LocalDecl => Replace 2020-09-17 13:59:22 -07:00
Leonardo de Moura
4ea8db2722 chore: cleanup 2020-09-17 13:50:40 -07:00
Leonardo de Moura
8142548237 fix: missing toggleInsideQuot
cc @Kha
2020-09-17 13:23:52 -07:00
Leonardo de Moura
d1c3ab3797 feat: many1Unbox and nodeSepBy1Unbox parser combinators
@Kha I removed the dummy parenthesizer/formatter for `withResultOf`,
and add proper ones for `many1Unbox` and `nodeSepBy1Unbox`.
2020-09-17 13:17:46 -07:00
Leonardo de Moura
3a6d579bbb feat: expand rewriteSeq macro 2020-09-17 12:32:22 -07:00
Leonardo de Moura
cf85080e7a feat: proper support for nullKind at evalTactic
@Kha When we write command macros, we can easily expand a command
into multiple ones by using `mkNullNode [cmd_1, ... cmd_n]`. Before
this commit, a tactic macro that expands into a sequence of tactics
had to produce `mkNullNode [tac_1, "; ", ..., "; ", tac_n]`.
I forgot the ";" a few times, and it produces very counterintuitive
behavior. This commit is the last step for fixing this issue.
The previous commits add the `withResultOf p f` combinator that allows
us to implement variants of the `unboxSingleton` trick. Now,
```
`(tactic| t)
```
Produces just `t` as before, but
```
`(tactic| t_1; t_2)
```
produces
```
Syntax.node `Tactic.seq [[t_1, "; ", t_2]]
```
instead of
```
Syntax.node `null [t_1, "; ", t_2]
```
2020-09-17 12:20:57 -07:00
Leonardo de Moura
2dafdec000 feat: use withResultOf combinator instead of unboxSingleton parameter 2020-09-17 12:12:12 -07:00
Leonardo de Moura
4265348bed feat: add withResultOf parser combinator and unboxSingleton 2020-09-17 12:03:16 -07:00
Leonardo de Moura
56f8103e66 chore: improve error message for rw [] 2020-09-17 10:55:51 -07:00
Leonardo de Moura
e9d65dd2de chore: improve sanitizeNames superscripts
cc @Kha
2020-09-17 08:57:54 -07:00
Leonardo de Moura
71f91cca23 chore: make sure isClass? return none when argument contains type errors
This is particularly useful for the delaborator when trying to pretty
print code that contains type errors.
2020-09-17 08:24:06 -07:00
Leonardo de Moura
57bed74871 chore: add Rewrite.lean 2020-09-17 08:15:58 -07:00
Leonardo de Moura
f4aabaecae refactor: move Lean.quote to LeanInit
cc @Kha
2020-09-17 08:15:58 -07:00
Leonardo de Moura
9d1f2b644f chore: rwRuleSeq ; => , 2020-09-17 08:15:58 -07:00
Sebastian Ullrich
26ed304071 fix: pretty print simplified macro scopes 2020-09-17 17:13:50 +02:00
Sebastian Ullrich
3834a89cdc feat: activate new pretty printer 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
98453c468b feat: formatter: don't escape inaccessible names 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
9b6370bdbe feat: formatter: escaping compound identifiers 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
0b9e46eee5 chore: universe-+ spacing 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
fad4660135 feat: pretty print space between binders 2020-09-17 08:12:28 -07:00
Sebastian Ullrich
131f30f7a9 feat: pretty print tuples 2020-09-17 08:12:28 -07:00