Commit graph

520 commits

Author SHA1 Message Date
Sebastian Ullrich
bbf6c717fc feat: introduce arg precedence 2021-03-22 16:33:37 +01:00
Sebastian Ullrich
725c0c1911 chore: implement lhs prec 2021-03-22 16:33:37 +01:00
Sebastian Ullrich
3d90850fdd feat: add syntax for specifying LHS precedence on trailing parsers 2021-03-22 16:33:36 +01:00
Leonardo de Moura
03e3a1cc6b chore: remove hack
It produces weird error messages in some examples, and it will be
obsolete after the new precedence feature.
2021-03-19 11:09:18 -07:00
Sebastian Ullrich
54405c4543 fix: automatically wrap many/sepBy items in null nodes where necessary 2021-03-19 15:15:55 +01:00
Leonardo de Moura
9daed5e91d chore: add checkLinebreakBefore 2021-03-18 06:43:03 -07:00
Leonardo de Moura
60a1b828ad fix: fixes #348 2021-03-16 17:50:40 -07:00
Sebastian Ullrich
75a97fad94 feat: nicer token parse errors 2021-03-14 08:23:32 -07:00
Sebastian Ullrich
9f21d6fd64 fix: preserve token parse errors 2021-03-14 08:23:32 -07:00
Leonardo de Moura
1df84e3a6d feat: allow haveDecl, sufficesDecl, letRecDecls in antiquotations 2021-03-12 17:40:16 -08:00
Leonardo de Moura
bf8119a5cd chore: convert keywords to snake_case
Again `!` is only for functions that can panic.
2021-03-12 13:34:51 -08:00
Leonardo de Moura
df994fd16f fix: add checkColGe to matchAlt
@Kha this is a fix for the example that @gebner posted on Zulip.
There are other possible workarounds, but I think this one is
"intuitive".

Here is the problem description and workaround.
We currently use the `withPosition` combinator at `matchAlts`. The
original motivation was nested `match`-expressions without
parenthesis.
We also have the `checkColGt` in the application parser.

Thus, `frob 5` is not parsed as an application. That is, the term
parser after the `then` keyword stops at `frob`.
Then, we get the weird "expected 'else'" error message at `5` :)

In this commit, I add a `checkColGe` check at the beginning of each
alternative right-hand-side.

The effect on the stdlib was minimal. It basically affected old code
that used the Lean 3 workaround for partial functions
```
partial def f : N -> N | i =>
  ...
```
In Lean 4, we can use the more natural
```
partial def f (i : N) : N :=
...
```
or
```
partial def f : N -> N := fun i =>
...
```

It also affected code such as
```
instance : Repr String.Iterator where
  reprPrec | ⟨s, pos⟩, prec =>
    Repr.addAppParen ("String.Iterator.mk " ++ reprArg s ++ " " ++ reprArg pos) prec
```
This is a workaround for a missing feature. We really wanted to write
```
instance : Repr String.Iterator where
  reprPrec ⟨s, pos⟩ prec :=
    Repr.addAppParen ("String.Iterator.mk " ++ reprArg s ++ " " ++ reprArg pos) prec
```
2021-03-12 11:06:07 -08:00
Leonardo de Moura
be841a7cad chore: throwError! => throwError, throwErrorAt! => throwErrorAt
@Kha I marked the corresponding methods as `protected`.
I currently can't stand `throw_error`, and I am optimistic about
server highlighting feature you are working on :)
2021-03-11 11:59:45 -08:00
Leonardo de Moura
ffb57e661f chore: remove old notation 2021-03-11 11:24:52 -08:00
Leonardo de Moura
1112ab6eff chore: use new notation 2021-03-11 11:19:33 -08:00
Leonardo de Moura
ca0baf12b6 chore: avoid ! suffix in builtin notation 2021-03-11 10:58:06 -08:00
Leonardo de Moura
5049d92968 chore: remove let! and let* notation 2021-03-11 10:42:50 -08:00
Leonardo de Moura
a97bdd6a67 chore: add let_delayed and let_fun notation
They will replace `let*` and `let!`
2021-03-11 10:31:04 -08:00
Leonardo de Moura
164577d94e chore: remove parser! and tparser!
The new macros are called "leading_parser` and `trailing_parser`.

cc @Kha
2021-03-11 09:36:58 -08:00
Leonardo de Moura
327717ade8 chore: add leading_parser and trailing_parser notation
It will replace `parser!` and `tparser!`
2021-03-11 09:08:35 -08:00
Leonardo de Moura
9f88ea8047 chore: remove old decide!, nativeRefl!, and nativeDecide! 2021-03-11 08:06:20 -08:00
Leonardo de Moura
90c5f35702 refactor: implement decide and nativeDecide as tactics
TODO: update stage0 and activate
2021-03-11 07:50:54 -08:00
Leonardo de Moura
b3d83aa199 feat: set_option parser for terms and tactics 2021-03-06 15:38:02 -08:00
Leonardo de Moura
4a39201d55 fix: ambiguity
```
def f (x : Nat) : IO Unit := do
IO.println x

open Nat in
def g (x : Nat) := succ x
```

cc @Kha
2021-03-06 15:33:00 -08:00
Leonardo de Moura
4bcfc5f9a6 feat: open parser for terms and tactics 2021-03-06 15:32:59 -08:00
Leonardo de Moura
960e964b71 feat: allow user to "erase" [simp] lemmas 2021-03-04 11:36:12 -08:00
Leonardo de Moura
c5673b6025 feat: auxiliary tactic for erasing auxiliary discriminants 2021-02-17 16:59:21 -08:00
Leonardo de Moura
e3c3fc3165 feat: add helper macro forIn!
We are going to write a custom elaborator for `forIn` applications.
2021-02-05 16:51:06 -08:00
Sebastian Ullrich
4772fb5849 feat: delaborator: use if prop 2021-02-02 13:54:34 +01:00
Sebastian Ullrich
0c91b3769e chore: replace variables in src/ 2021-01-22 14:36:05 +01:00
Sebastian Ullrich
8a02dfec4f feat: subsume variables under variable
/cc @leodemoura
2021-01-22 14:36:05 +01:00
Leonardo de Moura
ea0fda39bc chore: Declaration.lean naming convention
`Declaration.lean` was one of the first Lean 4 files, and was still
using an old naming convention.

cc @Kha
2021-01-20 17:07:02 -08:00
Sebastian Ullrich
21a826ee51 chore: naming 2021-01-20 22:47:18 +01:00
Sebastian Ullrich
79107a2316 feat: copy & store whole ref range in SourceInfo 2021-01-20 16:48:50 +01:00
Sebastian Ullrich
021a823f49 feat: add option printMessageEndPos 2021-01-15 16:27:59 +01:00
Sebastian Ullrich
720f06d251 fix: interpreted bracketedBinder.quot 2021-01-15 14:34:06 +01:00
Leonardo de Moura
308c61027a feat: save doc strings
We can now document `let rec` too.
2021-01-10 07:13:33 -08:00
Leonardo de Moura
f0ac477d2e feat: add sanity checks 2021-01-01 18:31:28 -08:00
Leonardo de Moura
6aab25b3cc chore: add missing ppSpace 2020-12-30 11:23:16 -08:00
Leonardo de Moura
bf88656288 feat: add binrel! parser
It is a helper macro for using binary relations such as `<` and `>`.
2020-12-29 15:11:28 -08:00
Leonardo de Moura
41308c9848 feat: add parser for annotating terms that should not be indexed 2020-12-28 17:21:33 -08:00
Leonardo de Moura
f53721e1c9 chore: adapt code to previous change 2020-12-23 08:31:20 -08:00
Leonardo de Moura
e74ba14f4c feat: modify structSimpleBinder parser
@Kha It felt odd that we can write
```
   map f x := ...
```
in instances, but we had to write
```
   map (f x) := ...
```
when setting the field default value in a class.
2020-12-23 08:23:14 -08:00
Leonardo de Moura
78aa3d8e72 chore: use deriving BEq 2020-12-22 18:10:20 -08:00
Leonardo de Moura
7b813622c6 chore: increase precedence of |>, <|, $ parsers
@Kha Now, all parsers defined by `Init/Std/Lean` packages have
precedence >= `min` and <= `max`.
The only exception is `<|>` since it is an infix operator sharead with
the tactic DSL.
BTW, the meaning of `f $ a <|> b` changed with this commit.
It was `f (a <|> b)`, and now is `(f a) <|> b`. The problem is that
the precedence of the `$` parser is now greater than the `<|>` parser.

I will try another experiment where I make sure we do not "reuse"
term infix operators in the tactic DSL.
2020-12-22 14:10:07 -08:00
Leonardo de Moura
cc34733e52 fix: update builtin precedences for |>. and macroDollarArg 2020-12-22 14:10:06 -08:00
Leonardo de Moura
7d1e493531 chore: reactivate tactic match and introMatch 2020-12-22 07:15:47 -08:00
Leonardo de Moura
f34bf82e0f chore: move tactic parsers introMatch and match to Lean/Parser/Tactic 2020-12-22 07:11:06 -08:00
Leonardo de Moura
a05ca020f4 chore: prepare to move tactic match parser back to Lean/Parser/Tactic 2020-12-22 06:52:41 -08:00
Sebastian Ullrich
1c31240ebb feat: token antiquotations in macro 2020-12-22 13:11:04 +01:00