Commit graph

66 commits

Author SHA1 Message Date
Sebastian Ullrich
73cf3533a1 fix: count quotation depth in parser correctly 2021-04-29 13:33:48 +02:00
Leonardo de Moura
1c23d68c6a feat: add (generalizing := true/false) optional attribute to match 2021-04-15 17:04:25 -07:00
Sebastian Ullrich
bbf6c717fc feat: introduce arg precedence 2021-03-22 16:33:37 +01:00
Leonardo de Moura
60a1b828ad fix: fixes #348 2021-03-16 17:50:40 -07: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
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
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
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
Sebastian Ullrich
bc3e9ce961 feat: if let pat ← ... 2020-12-20 23:58:29 +01:00
Sebastian Ullrich
90f747e346 fix: don't change antiquotations semantics in do if 2020-12-20 17:51:37 +01:00
Sebastian Ullrich
eeb0cad29e feat: if let
/cc @leodemoura
2020-12-20 16:46:03 +01:00
Leonardo de Moura
0911936502 feat: parallel for notation 2020-12-19 19:26:53 -08:00
Leonardo de Moura
f2ea45e68a feat: expose doSeq and termBeforeDo parsers
Users can use them to extend the `do` DSL.
2020-12-10 19:10:25 -08:00
Sebastian Ullrich
4dfa7e1187 feat: use actual separator in sepBy antiquotation scope 2020-12-09 17:48:05 +01:00
Leonardo de Moura
c476954eef feat: heterogeneous OrElse and AndThen
@Kha I had a few issues similar to the `Append` issues.
We used a similar idiom for writing builtin parsers where we may write
```
def p : Parser := "foo " >> "bla "
```
as a shorthand for
```
def p : Parser := symbol "foo " >> symbol "bla "
```
I want to support `builtin syntax` one day :)

That being said, we should decide whether we keep `HAppend`, `HOrElse`,
and `HAndThen` or not.
The only one I wish I had in the past is `HAndThen`.
2020-12-01 18:32:24 -08:00
Leonardo de Moura
2909313475 fix: doLetArrow and doReassignArrow
@Kha the new tests did not work without this fix.
The `| _ =>` was being parsed as part of the `doLetArrow` and `doReassignArrow`
2020-11-26 10:29:08 -08:00
Sebastian Ullrich
375e6232e0 chore: introduce doSeqItem kind 2020-11-25 12:10:49 +01:00
Sebastian Ullrich
bd7bb6f5b5 fix: do formatting 2020-11-25 11:30:24 +01:00
Leonardo de Moura
360fa1638f chore: rename Parser.try to Parser.atomic
Reason: `try` is a keyword.

cc @Kha
2020-11-17 08:25:01 -08:00
Leonardo de Moura
cae6aa95dc feat: support simpleBinder at letDecl 2020-11-12 13:25:38 -08:00
Leonardo de Moura
1c558d279f feat: add mut modifier to doLet 2020-11-07 17:32:13 -08:00
Leonardo de Moura
89fd299c9e chore: prepare mut 2020-11-07 17:32:12 -08:00
Leonardo de Moura
d20081c548 feat: add term version of unless, for, try, and return notations 2020-10-31 19:19:17 -07:00
Leonardo de Moura
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
d25ec3417b chore: remove some [inline] and [specialize] annotations from Parser/Basic 2020-10-21 11:27:18 -07:00
Leonardo de Moura
702ceb7a3f fix: return optional result
cc @Kha
2020-10-20 09:33:50 -07:00
Leonardo de Moura
ef18b0ab49 chore: use [builtinInit] 2020-10-19 14:58:38 -07:00
Leonardo de Moura
c7efb1d37d fix: do notation else if
The following `do` block
```lean
if c_1 then
  action_1
else
  if cond_2 then
    action_2
  action_3
```
was being being parsed as
```lean
if c_1 then
  action_1
else if cond_2 then
  action_2
action_3
```

cc @Kha
2020-10-19 14:29:31 -07:00
Leonardo de Moura
14414e3400 feat: nested do parser 2020-10-15 17:04:35 -07:00
Leonardo de Moura
60e4f4fee1 feat: improve notFollowedBy error messages 2020-10-15 17:01:10 -07:00
Leonardo de Moura
d2e5c1c300 feat: improve dbgTrace! macro 2020-10-13 12:38:04 -07:00
Leonardo de Moura
9538772c1c chore: do not use string interpolation by default at dbgTrace!
It is nice to be able to write `dbgTrace! x` instead of `dbgTrace! "{x}"`
2020-10-09 20:49:39 -07:00
Leonardo de Moura
bca81714fe feat: println! and dbgTrace! macros with string interpolation 2020-10-09 17:19:04 -07:00
Leonardo de Moura
8a6cb1842f feat: expand doTry
@Kha I did not implement support for reassignments and `continue`,
`break`, `return` inside the `finally` clause. It is doable, but it
feels like unnecessary complexity. We currently don't have any
instance in our code base where this would be useful.
2020-10-08 19:39:36 -07:00
Leonardo de Moura
7f5af84660 chore: add doElem quotation parser 2020-10-08 13:45:53 -07:00
Leonardo de Moura
5d8764dd92 feat: take doElem at doLetArrow and doReassignArrow 2020-10-07 16:49:28 -07:00
Sebastian Ullrich
5d76a981b0 chore: adjust pp spacing 2020-10-07 09:44:04 +02:00
Leonardo de Moura
294a750110 feat: expand doMatch 2020-10-06 19:07:47 -07:00
Leonardo de Moura
cebadf9efd chore: group many elements
TODO: the parser combinators `many` and `sepBy` should do it.
2020-10-06 06:43:19 -07:00
Leonardo de Moura
7325dcd630 feat: use do at for-in and unless notations 2020-10-05 09:43:11 -07:00
Leonardo de Moura
4e7fd4b4bf chore: add doSeqIndent kind 2020-10-03 08:22:02 -07:00
Leonardo de Moura
a5daaee3ed chore: do syntax adjustments 2020-10-03 07:33:18 -07:00
Leonardo de Moura
96f5c51a3e fix: doElem issues 2020-10-02 18:58:43 -07:00
Leonardo de Moura
c40ec0128d fix: return value is optional 2020-10-02 18:09:42 -07:00
Leonardo de Moura
35e401e915 chore: naming consistency 2020-10-02 15:47:12 -07:00
Leonardo de Moura
40640b85bd fix: doSeqBracketed parser
It was failing to parse
```
def f2 (x : Nat) : IO Nat := do {
  let y := 1;
  if x > 0 then
    y := y + 1;
  IO.println y
}
```

cc @Kha
2020-10-02 15:05:22 -07:00
Leonardo de Moura
379e34a910 feat: do reassignment parsers 2020-10-02 13:16:55 -07:00