Commit graph

122 commits

Author SHA1 Message Date
Leonardo de Moura
633578cfaf chore: use StateRefT macro 2020-10-27 13:05:12 -07:00
Sebastian Ullrich
d8a1742d57 feat: introduce suppressInsideQuot 2020-10-27 16:50:58 +01:00
Sebastian Ullrich
20ed65605b fix: don't parenthesize juxtaposed tactics 2020-10-27 14:09:33 +01:00
Sebastian Ullrich
84692acd0e fix: do not introduce parentheses implied by indentation 2020-10-27 14:09:33 +01:00
Sebastian Ullrich
5f67c359bc chore: simplify formatter token separation logic 2020-10-27 14:09:33 +01:00
Sebastian Ullrich
33c861a80e fix: parenthesizer: really make sure a trailing parser is of the same category as the continuation 2020-10-27 14:09:33 +01:00
Sebastian Ullrich
eb125c52f1 fix: never pretty-print whitespace before checkNoWsBefore 2020-10-27 14:09:33 +01:00
Leonardo de Moura
7e244686e9 chore: remove old notation 2020-10-26 09:16:51 -07:00
Leonardo de Moura
13c2a8ff51 chore: remove #lang lean4 header 2020-10-25 09:54:07 -07:00
Leonardo de Moura
af968c60e6 chore: cleanup 2020-10-22 07:32:23 -07:00
Sebastian Ullrich
7f8d6b803f feat: interpolatedStr pretty printer 2020-10-22 15:01:53 +02:00
Leonardo de Moura
b555307f06 chore: move to new frontend 2020-10-21 16:35:50 -07:00
Leonardo de Moura
8abbf7634d chore: move to new frontend 2020-10-21 14:16:41 -07:00
Leonardo de Moura
7111eb4d79 chore: move to new frontend 2020-10-21 13:30:43 -07:00
Leonardo de Moura
e5c17463c5 chore: move to new frontend 2020-10-21 10:06:53 -07:00
Leonardo de Moura
faa59ead97 chore: move to new frontend 2020-10-20 13:46:16 -07:00
Sebastian Ullrich
e8cf086641 fix: synthesize pretty printers early 2020-10-20 09:50:54 +02: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
e2ecefb67b chore: add support for error parser in the pretty printer 2020-10-15 16:31:35 -07:00
Sebastian Ullrich
2ccd382e6f refactor: formatter: remove unnecessary concatenation 2020-10-14 14:24:47 +02:00
Sebastian Ullrich
8c2953400d perf: formatter: smaller Format objects 2020-10-14 14:24:47 +02:00
Sebastian Ullrich
78ffc72150 chore: remove ppGroups beneficial only for group but not fill 2020-10-14 14:24:47 +02:00
Sebastian Ullrich
88af639346 feat: Formatter: default to Format.fill instead of Format.group 2020-10-14 14:24:47 +02:00
Leonardo de Moura
9af0a0e18b feat: add withReader method
@Kha `withReader` is a well-behaved version of `adaptReader`. `adaptReader` is
too general, and it often produces counterintuitive elaboration
errors.

Here are two super annoying issues I hit all the time:
1- `adaptReader` + polymorphic code
```
def ex1 : ReaderT Nat IO Unit :=
adaptReader (fun x => x + 1) $
  IO.println "foo" -- 3 Errors here failed to synthesize `Monad ?m` and  `MonadIO ?m`, and don't know how to synthesize `Type → Type`
```

2- `adaptReader` and notation that requires the expected type
```
structure Context :=
(x y : Nat)

def ex2 : ReaderT Context IO Nat :=
adaptReader (fun s => { s with x := 10 }) $ -- Error at the structure instance
  ...
```
In the example above, I have to write `fun (s : Context) => ...` to
fix the problem.

The two problems above happen in the old and new frontends. However,
there is a new problem specific for the new frontend. In the new
frontend, a `do` is only elaborated when the expected type is known.
So, `adaptReader (fun ctx => ...) do ...` seldom works :(

As I said above, the issue is that `adaptReader` is too general. Its
type is
```
  {ρ ρ' : Type u_1} → {m m' : Type u_1 → Type u_2} → [MonadReaderAdapter ρ ρ' m m'] → {α : Type u_1} → (ρ' → ρ) → m α → m' α
```

`withReader` is a simpler version of `adaptReader`
```
withReader : {ρ : Type u_1} → {m : Type u_1 → Type u_2} → [MonadWithReader ρ m] → {α : Type u_1} → (ρ → ρ) → m α → m α
```
It doesn't have any of the problems above. Moreover, I managed to replace
every single instance of `adaptReader` with `withReader` at the stdlib
and tests. We don't need the `adaptReader` generality.
2020-10-13 15:00:17 -07:00
Leonardo de Moura
3bd75d51d5 feat: add ParserDescr.noWs 2020-10-09 16:26:49 -07:00
Leonardo de Moura
e021a7d011 chore: remove symbolNoWs
@Kha This is a leftover from the time precedence was associated with
tokens instead of parsers.
2020-10-09 16:17:56 -07:00
Leonardo de Moura
7013ea4098 feat: add interpolatedStr to ParserDescr and Syntax 2020-10-09 14:04:53 -07:00
Leonardo de Moura
36696d726d feat: add String Interpolation 2020-10-09 13:40:35 -07:00
Sebastian Ullrich
f0dad079ad fix: checkWsBefore.formatter 2020-10-07 10:01:17 +02:00
Sebastian Ullrich
69fe4c7338 fix: formatter: must backtrack on symbols as well 2020-10-07 09:46:47 +02:00
Sebastian Ullrich
21f1a66ceb feat: add & use ppDedent parser combinator 2020-10-07 09:46:47 +02:00
Sebastian Ullrich
b1e35d6ca9 fix: ppGroup 2020-10-07 09:44:05 +02:00
Sebastian Ullrich
e777478aa1 fix: Formatter.pushLine 2020-10-07 09:44:05 +02:00
Sebastian Ullrich
5d76a981b0 chore: adjust pp spacing 2020-10-07 09:44:04 +02:00
Leonardo de Moura
5c74c408ae chore: remove nodeSepBy1Unbox combinator 2020-10-06 08:28:40 -07:00
Leonardo de Moura
9a551d9219 feat: add withForbidden and withoutForbidden parser combinators 2020-10-05 09:36:28 -07:00
Sebastian Ullrich
d51101b884 feat: sanitize Syntax in messages
Fixes #182
2020-09-29 07:59:22 -07:00
Leonardo de Moura
1fcdbaf223 feat: add withoutPosition combinator 2020-09-28 17:10:57 -07:00
Leonardo de Moura
6ddec22763 refactor: simplify withPosition combinator
Add `checkColGt`
2020-09-28 17:10:56 -07:00
Leonardo de Moura
453ce9b3b8 feat: add eoi parser 2020-09-27 16:54:19 -07:00
Leonardo de Moura
3d6cc2de08 feat: add notFollowedByCategoryToken parser 2020-09-26 15:53:23 -07:00
Leonardo de Moura
e31fd665f0 feat: add checkLineLe parser 2020-09-26 14:03:28 -07:00
Sebastian Ullrich
fa55c1e088 fix: pretty printing loose bvars
Fixes #192
2020-09-23 11:13:23 +02:00
Leonardo de Moura
f4b5ec710f fix: fixes #175 2020-09-21 17:12:07 -07:00
Leonardo de Moura
b0564a32b9 feat: add AttrM
We are going to use `AttrM` to implement solution 2 described at https://github.com/leanprover/lean4/issues/175
2020-09-21 16:44:20 -07:00
Leonardo de Moura
f679b7d803 feat: add notFollowedBy to syntax 2020-09-19 15:43:44 -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