Commit graph

197 commits

Author SHA1 Message Date
Leonardo de Moura
157ef80c5a feat: match auto generalization 2021-04-16 21:48:38 -07:00
Leonardo de Moura
1c23d68c6a feat: add (generalizing := true/false) optional attribute to match 2021-04-15 17:04:25 -07:00
Leonardo de Moura
abf78e162c feat: add notation for disabling implicit lambda feature
This notation will be useful for writing macros where
implicit lambdas are not desired.
2021-04-12 22:33:23 -07:00
Leonardo de Moura
2b9df7d8b9 chore: make it clear that implementation relies on the fact that both branches of the if-then-else generate a node with the same kind
Motivation: we want to change the kind used in the `group` combinator.
2021-04-07 22:02:17 -07:00
Leonardo de Moura
0717c3d0b2 chore: adding helper parser completion
I am hitting many error recovery problems. This is an attempt to make
auto-completion more robust.
For example, we currently can't auto complete inside of parentheses.
The syntax tree for the syntactically incorrect tern `(s. , 0)` is
```
(Term.paren "(" [(Term.proj `s ".")])
```
The elaborator for `paren` fails to match this partial syntax tree and
returns an error. I considered adding code to the `else` branch of
this elaborator and handle partial trees there. However, we would
still be losing information for the other elements of the tuple.
Example: no hover information for them.
The helper parser makes sure we don't lose information.
2021-04-05 18:44:01 -07:00
Leonardo de Moura
d6af843683 chore: remove completion auxiliary parser 2021-04-05 11:26:13 -07:00
Leonardo de Moura
e6dec2dd79 feat: don't allow whitespaces between . and field name 2021-04-05 07:11:14 -07:00
Leonardo de Moura
caae7952cd feat: add helper parsers for auto-completion 2021-04-01 23:31:38 -07:00
Sebastian Ullrich
bbf6c717fc feat: introduce arg precedence 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
Sebastian Ullrich
75a97fad94 feat: nicer 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
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
ffb57e661f chore: remove old notation 2021-03-11 11:24:52 -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
4bcfc5f9a6 feat: open parser for terms and tactics 2021-03-06 15:32:59 -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
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
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
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
Sebastian Ullrich
cf73233dd2 refactor: use quotations & implicit token positions from getRef to clean up a bit 2020-12-21 17:32:36 +01:00
Sebastian Ullrich
f9dcbbddc4 refactor: remove optional leading pipe from match, use many1Indent instead of sepBy1 2020-12-16 18:27:05 +01:00
Leonardo de Moura
97642bd000 fix: prio issue 2020-12-16 07:44:48 -08:00
Leonardo de Moura
a008816102 chore: remove workaround 2020-12-16 07:34:40 -08:00
Leonardo de Moura
7b67cd2c4a chore: fix priorities 2020-12-16 07:11:02 -08:00
Leonardo de Moura
16747d3986 chore: remove attrParam syntax category 2020-12-15 21:47:24 -08:00
Leonardo de Moura
901e58b131 fix: priority 2020-12-15 20:57:00 -08:00
Leonardo de Moura
ed87480093 refactor: move to attr syntax category 2020-12-15 20:22:04 -08:00
Leonardo de Moura
6100ed9283 feat: add LeadingIdentBehavior type
Different strategies for handling the leading identifier in the
`Pratt` parser loop.
2020-12-15 16:45:14 -08:00
Leonardo de Moura
9e3b3b2495 refactor: move attribute related parsers to separate file 2020-12-15 16:13:11 -08:00
Leonardo de Moura
c9f766af5a feat: we don't want attribute names as keywords 2020-12-15 15:59:48 -08:00
Leonardo de Moura
3ee6aec466 feat: add attr parser category 2020-12-15 15:44:46 -08:00
Leonardo de Moura
6985223a55 chore: switch to attrParam 2020-12-14 17:52:28 -08:00
Leonardo de Moura
69e8385f8d refactor: move prioParser to Term.lean 2020-12-14 17:33:38 -08:00
Leonardo de Moura
0004196977 feat: add attrParam builtin parsers 2020-12-14 17:27:28 -08:00
Leonardo de Moura
a3fe907a28 feat: add attrParam syntax category
cc @Kha
2020-12-14 16:45:05 -08:00
Leonardo de Moura
c5e201bce6 feat: add prec syntax category 2020-12-14 13:09:27 -08:00
Leonardo de Moura
ac692bfc79 feat: add new static quotations
For users that are writing (not-trivial) macros without `import Lean`.

cc @Kha
2020-12-14 09:21:26 -08:00
Sebastian Ullrich
314c5c9d41 feat: run single non-category quotation under interpreter as well 2020-12-14 17:13:59 +01:00
Sebastian Ullrich
a9bdb2f70a feat: prefer interpreter for running builtin parsers in quotations 2020-12-14 16:45:32 +01:00