Commit graph

26011 commits

Author SHA1 Message Date
Leonardo de Moura
7ec23f9401 fix: macro command syntax 2020-06-09 14:11:34 -07:00
Leonardo de Moura
a4f19aac32 fix: macro command 2020-06-09 14:11:34 -07:00
Leonardo de Moura
7fce8b5d1f fix: notation command
@Kha Note that I had to write the weird pattern

```
match_syntax stx with
| `(notation:$prec $items* => $rhs)    => expandNotationAux stx prec items rhs
| `(notation $noprec* $items* => $rhs) => expandNotationAux stx none items rhs
| _ => Macro.throwUnsupported
```

with the weird `$noprec*` to match the case where the optional
precedence is not provided. I realized this is not a bug, but
I guess most users will be puzzled by this behavior. If we had a kind
for `notationItem`, I would be able to write
```
`(notation $items:notationItems* => $rhs)
```
2020-06-09 14:11:34 -07:00
Sebastian Ullrich
a78ceb8121 fix: parenthesizer 2020-06-09 11:26:00 +02:00
Sebastian Ullrich
c8ee21747b chore: remove obsolete symbolAux, symbolNoWsAux 2020-06-09 10:37:00 +02:00
Leonardo de Moura
4250bc630e chore: fix tests 2020-06-08 16:18:46 -07:00
Leonardo de Moura
2b58ecea60 chore: fix test 2020-06-08 16:13:52 -07:00
Leonardo de Moura
f46dcd7a13 chore: fix some tests 2020-06-08 16:12:06 -07:00
Leonardo de Moura
aa49b3cdb1 feat: elaborate new syntax command 2020-06-08 16:12:06 -07:00
Leonardo de Moura
5099a0bf1b chore: update stage0 2020-06-08 16:12:06 -07:00
Leonardo de Moura
8972c7e666 feat: revised syntax commands 2020-06-08 16:12:06 -07:00
Leonardo de Moura
d2c2d95c47 chore: remove symbolAux 2020-06-08 16:12:06 -07:00
Leonardo de Moura
e525a8d7c3 chore: update stage0 2020-06-08 16:12:06 -07:00
Leonardo de Moura
dd1aa2f271 chore: improve error message
cc @Kha
2020-06-08 16:12:05 -07:00
Leonardo de Moura
c6ea675cae chore: fix test
@Kha The error message changed. Not sure the new one is expected. It
is due to the change in `trailingLoop`. We can discuss it in the next
meeting.
2020-06-08 16:12:05 -07:00
Leonardo de Moura
aa66fc376b chore: fix test 2020-06-08 16:12:05 -07:00
Leonardo de Moura
400aa435f3 fix: add missing precedence to liftMethod and remove unnecessary precedence from doLet 2020-06-08 16:12:05 -07:00
Leonardo de Moura
b3a8d417b2 chore: fix test 2020-06-08 16:12:05 -07:00
Leonardo de Moura
1554f7f99a fix: ParserDescr
This commit also adds the new constructor `ParserDescr.rblLt`
2020-06-08 16:12:05 -07:00
Leonardo de Moura
906e1b9d91 fix: reset should only be performed at trailingLoop 2020-06-08 16:12:05 -07:00
Leonardo de Moura
5f1831812a chore: missing [inline]s and typo 2020-06-08 16:12:05 -07:00
Leonardo de Moura
5765a1160d fix: Parser ==> TrailingParser 2020-06-08 16:12:05 -07:00
Leonardo de Moura
fa2e943c27 fix tokenFnAux 2020-06-08 16:12:05 -07:00
Leonardo de Moura
8dde9715a9 refactor: associate precedences to parsers instead of tokens
@Kha This is working in progress.
I am convinced we should associated the precedence to parsers. A lot
of weird stuff is gone :)
2020-06-08 16:12:05 -07:00
Leonardo de Moura
52c7709cb3 fix: longestMatch at trailing parsers
Before this commit, if we execut `longestMatch [p1, p2]` in a
trailing parser where both `p1` and `p2` succeed, then an incorrect
syntax tree is generated by `p2`. The issue is that before executing
`p2`, the trailing stack is of the form
`#[..., left, syntax-by-p1]`
Then, the trailing parser `p2` incorrectly assumes that `syntax-by-p1`
was the "left" syntax node.
This commit fix this issue by storing the `left` node at the
`ParserContext` at `trailingLoop`

@Kha This bug was introduced when we unified leading and trailing
parsers. I think this is the simplest solution.
We can observe the bug before this commit by using
```
set_option syntaxMaxDepth 1000
set_option trace.Elab true
```
at `choiceMacroRules.lean`.

It is funny the correct result was produced even with the bug.
It was working because the `macro_rules` was matching the
buggy syntax with the nested `syntax-by-p1` there :)
2020-06-08 14:34:50 -07:00
Leonardo de Moura
8b1cb0fcb8 doc: errToSorry field 2020-06-08 14:28:50 -07:00
Leonardo de Moura
62cf913d6a fix: interaction between errToSorry and observing.
@Kha I implemented the solution 1 I described at Zulip.
I also tried to document the issue, and made sure test
`choiceMacroRules` fail if the bug is reintroduced.
2020-06-08 12:37:43 -07:00
Leonardo de Moura
9aa5a5c298 chore: update stage0 2020-06-03 18:11:42 -07:00
Leonardo de Moura
7a323a0c7b feat: allow parser! and tparser! to set the parser precedence 2020-06-03 18:11:13 -07:00
Leonardo de Moura
947369b4ce chore: Parenthesizer issues after removing sortApp
@Kha Could you please double check these modifications.

I added a no-op for `checkRbpLt`. It is used at the `Sort` and `Type`
parsers.
As I described in previous commits, the `checkRBPGreater` comment and
implementation were misleading. It was actually succeeding when the
rbp was less than or equal to the given parameter. So, it was renamed
to `checkRbpLe`. So, is the depArrow parenthesizer ok? I did not check.

I updated the PPRoundtrip.lean.expected.out to make sure the tests
succeed, but we should revise it if there is a problem with the
modifications at Parenthesizer.lean
2020-06-03 15:46:33 -07:00
Leonardo de Moura
cd4affd129 chore: update stage0 2020-06-03 15:33:02 -07:00
Leonardo de Moura
5f0dae3fcb fix: elabSort and elabTypeStx 2020-06-03 15:27:09 -07:00
Leonardo de Moura
2fbf3cff15 chore: update stage0 2020-06-03 15:26:59 -07:00
Leonardo de Moura
9a349a913a chore: remove sortApp
@Kha Note that `checkRBPGreater` comment and name were incorrect. It
was actually checking whether the RBP <= lower
2020-06-03 15:18:16 -07:00
Leonardo de Moura
e252446432 doc: cite "Generalizing Monads to Arrows"
cc @Kha
2020-06-01 08:02:32 -07:00
Sebastian Ullrich
c81f4605e3 doc: Parser.lean 2020-06-01 07:53:09 -07:00
Sebastian Ullrich
6614b4d6e3 fix: use exact instead of prefix token match when inheriting precedence
/cc @leodemoura :)
2020-05-28 14:14:52 +02:00
Leonardo de Moura
5dffa0093a feat: retrieve implicit lbp from Environment at syntax command
@Kha It is not clear to me why I had to change the following line
```
-syntax term ">>>" term : foo
+syntax term:1 ">>>":1 term : foo
```
The test breaks without it.
2020-05-27 17:11:57 -07:00
Leonardo de Moura
bbdf1f39ed chore: update stage0 2020-05-27 16:15:19 -07:00
Leonardo de Moura
dbe4aa447e chore: explicit lbp at ParserDescr.symbol 2020-05-27 16:12:53 -07:00
Leonardo de Moura
6e5cd5fcc0 chore: change coercion from String to Parser
@Kha
I kept `TokenInfo` as is. That is, the `lbp` field is still `Option Nat`.
I changed my mind because we have the combinator `NonReservedSymbol`.
It feels weird to have a combinator that does not create a keyword,
but sets the `lbp`. Recall that it is used at `Lean/Parser/Tactic.lean`.

Other observations:

- We use symbols in auxiliary constructions (e.g., `mkAntiquot`). It
feels weird to set their `lbp` there.

- It felt weird to specify the `lbp` in places such as
```
def structCtor := parser! ident >> optional inferMod >> symbol " :: " 67
```

- We have a few parsing rules where the same symbol appears twice.
It is funny to set the `lbp` twice. Note that the approach we
discussed yesterday (retrieving the `lbp` from the `Environment`)
would not work here.
2020-05-27 15:59:12 -07:00
Leonardo de Moura
e51ed38bd0 chore: update stage0 2020-05-27 14:15:00 -07:00
Sebastian Ullrich
7a664863fd fix: leanmake: allow users to add custom LEAN_PATH 2020-05-27 19:46:35 +02:00
Sebastian Ullrich
7e13952510 feat: simplify LEAN_PATH 2020-05-27 19:46:16 +02:00
Sebastian Ullrich
8227eea87b chore: simplify stdlib.make.in 2020-05-27 19:42:44 +02:00
Leonardo de Moura
50fc961037 chore: update stage0 2020-05-26 15:05:01 -07:00
Leonardo de Moura
862795e9e9 fix: usesLeanAPI 2020-05-26 15:05:01 -07:00
Leonardo de Moura
17b6957f6c chore: fix tests 2020-05-26 15:05:01 -07:00
Leonardo de Moura
f820341430 chore: update stage0 2020-05-26 15:05:01 -07:00
Leonardo de Moura
cef80c707b fix: missing deps 2020-05-26 15:05:01 -07:00