Commit graph

19987 commits

Author SHA1 Message Date
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
Leonardo de Moura
9c0bd9dd41 chore: fix tests 2020-05-26 15:05:00 -07:00
Leonardo de Moura
cd3d72190c chore: update stage0 2020-05-26 15:05:00 -07:00
Leonardo de Moura
4ccc3fef52 chore: move Init.Lean files to Lean package 2020-05-26 15:04:35 -07:00
Leonardo de Moura
b0dbaada54 chore: update stage0 2020-05-26 13:56:49 -07:00
Leonardo de Moura
4bca76a87e chore: use src/Lean.lean to initialize lean 2020-05-26 13:54:13 -07:00
Leonardo de Moura
49fc82c604 chore: add Lean package to leanc.in 2020-05-26 13:51:06 -07:00
Leonardo de Moura
f7818757ef chore: add Lean package to CMakeLists.txt 2020-05-26 13:50:04 -07:00
Leonardo de Moura
834286113f feat: add Lean package to builtin path 2020-05-26 13:43:19 -07:00
Leonardo de Moura
c765bd2a7e chore: update stage0 2020-05-26 13:39:48 -07:00
Leonardo de Moura
8d30f67823 feat: add Lean package 2020-05-26 13:39:03 -07:00
Sebastian Ullrich
c11e88c768 test: Reparen: don't remove parentheses in syntax quotations 2020-05-26 14:32:42 +02:00
Sebastian Ullrich
d25a4b311a fix: missing precedence 2020-05-26 14:32:42 +02:00
Sebastian Ullrich
674fea4876 fix: parenthesizer: adjust lbp after parenthesization 2020-05-26 14:32:42 +02:00
Sebastian Ullrich
e6d27c276b feat: #eval: capture stderr 2020-05-26 14:32:42 +02:00
Sebastian Ullrich
b519997b58 feat: parenthesizer: handle choice 2020-05-26 14:32:42 +02:00
Sebastian Ullrich
1cbe54fa44 fix: parenthesizer: backtracking special case 2020-05-26 14:32:42 +02:00
Sebastian Ullrich
60ac03916e feat: introduce anonymous antiquotations for all categories 2020-05-26 14:32:42 +02:00
Sebastian Ullrich
48246c8e4a feat: parenthesizer: support antiquotations 2020-05-26 11:47:38 +02:00
Sebastian Ullrich
b35b973a5d fix: precedence of ! in old frontend 2020-05-26 11:26:57 +02:00
Sebastian Ullrich
a884ea8656 feat: ToExpr (Option _) 2020-05-26 11:26:57 +02:00
Sebastian Ullrich
185b02a435 feat: parenthesize tactics 2020-05-26 11:26:57 +02:00
Sebastian Ullrich
95d03a123d fix: sepBy parenthesizer 2020-05-26 11:26:57 +02:00
Sebastian Ullrich
9247911e09 fix: basic parenthesizer approach, document 2020-05-26 11:26:57 +02:00
Sebastian Ullrich
3431d934de fix: initSearchPath: use valid default value 2020-05-26 11:26:57 +02:00