Commit graph

26011 commits

Author SHA1 Message Date
Leonardo de Moura
f679b7d803 feat: add notFollowedBy to syntax 2020-09-19 15:43:44 -07:00
Leonardo de Moura
c43450f027 feat: macros for the syntax category
This is the last of a series of commits for adding this feature.
2020-09-19 15:00:41 -07:00
Leonardo de Moura
c2c57b4a5e chore: update stage0 2020-09-19 14:44:48 -07:00
Leonardo de Moura
ee6d723554 feat: add stx.quot 2020-09-19 14:40:17 -07:00
Leonardo de Moura
f876177f26 feat: expand macros in syntax declaration 2020-09-19 14:39:49 -07:00
Leonardo de Moura
17d4117637 chore: remove temporary hacks 2020-09-19 14:21:38 -07:00
Leonardo de Moura
a96e5d4bcd chore: update stage0 2020-09-19 14:17:10 -07:00
Leonardo de Moura
25b40b4b89 chore: disable macro 2020-09-19 14:15:24 -07:00
Leonardo de Moura
6307e1b855 chore: update stage0 2020-09-19 14:15:11 -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
f1386672c8 chore: disable format-reparse test until hard linebreaks are working 2020-09-18 13:15:40 -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
fbbc77ceb6 chore: update stage0 2020-09-18 10:34:22 -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
c996bc1f84 test: assertAfter 2020-09-17 19:35:16 -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
c2b35a89f5 chore: increase fuel to make sure test works 2020-09-17 17:30:29 -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
605057b62c chore: update stage0 2020-09-17 12:15:13 -07:00
Leonardo de Moura
4414aefd14 chore: update stage0 2020-09-17 12:14:39 -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
0a6a1396f8 chore: update stage0 2020-09-17 12:06:04 -07:00