Commit graph

26011 commits

Author SHA1 Message Date
Leonardo de Moura
7de9cfeac8 chore: fix StructInst and add mkGroupNode 2021-04-07 22:46:07 -07:00
Leonardo de Moura
0e21fb0937 chore: update stage0 2021-04-07 22:46:07 -07:00
Leonardo de Moura
578b3b822f fix: do not use nullKind for group combinator
We use `nullKind` for the `group` parser combinator.
When pattern matching `nullKind` nodes, we check their arities.
So, error recovery often fails for parsers that use the `group`
combinator.
For example, we have the parser
```
def whereDecls := leading_parser "where " >> many1Indent (group (letRecDecl >> optional ";"))
```
If there is syntax error at `letRecDecl`, the node corresponding to
```
group (letRecDecl >> optional ";")
```
will contain only one child, and the pattern matching at
```
def expandWhereDecls (whereDecls : Syntax) (body : Syntax) : MacroM Syntax :=
  match whereDecls with
  | `(whereDecls|where $[$decls:letRecDecl $[;]?]*) => `(let rec $decls:letRecDecl,*; $body)
  | _ => Macro.throwUnsupported
```
fails, and we can't elaborate the partial syntax tree for
`letRecDecl`, and auto-completion will not work there.

We address this issue by using a new kind for the `group` combinator.
The idea is to pattern match `group` as we pattern match `node`s with
proper syntax node kinds. This change is consistent with the way we
use `group` where it mainly a convenience for saving us the trouble of
defining a new parser definition that is used only once.
2021-04-07 22:30:51 -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
390a476caf fix: incorrect use of unreachable! 2021-04-07 18:11:10 -07:00
Leonardo de Moura
6d361b91b5 Feat: Add getAllParentStructures 2021-04-07 18:06:10 -07:00
Leonardo de Moura
6c0f3c277f fix: ignore syntactically incorrect commands that do not contain any symbol
This kind of broken command does not have a position information, and
was producing a panic message in the server because it makes the
reasonable assumption that every command returned by `parserCommand`
has a position.
2021-04-07 14:46:13 -07:00
Leonardo de Moura
ca0912c6e3 chore: update stage0 2021-04-07 11:17:23 -07:00
Leonardo de Moura
7c8e27b044 chore: minor 2021-04-07 11:14:46 -07:00
Leonardo de Moura
98c6fd1151 fix: another antipattern 2021-04-07 10:42:54 -07:00
Leonardo de Moura
132d6de78d fix: antipattern
We should never assume a `Syntax` node has a specific number of
children because the parser error recovery may produce partial
abstract syntax trees. We should use `stx[i]` instead because
`Syntax.getOp` returns `Syntax.missing` when `i` is out of bounds.
2021-04-07 10:26:05 -07:00
Leonardo de Moura
393adadf9a chore: leftovers 2021-04-07 10:26:05 -07:00
Sebastian Ullrich
0396168c2c test: make sure the interactive test would have actually failed without the fix 2021-04-07 18:05:48 +02:00
Sebastian Ullrich
5b5a882da6 fix: watchdog: do not reorder messages while delaying edits 2021-04-07 17:12:37 +02:00
Sebastian Ullrich
2de5b141eb test: interactive: support inserting text 2021-04-07 17:12:37 +02:00
Sebastian Ullrich
43fcf69485 fix: watchdog: mark request as pending even if worker crashed 2021-04-07 16:48:12 +02:00
Sebastian Ullrich
7de11d2aa3 doc: quickstart: beware the Windows 2021-04-07 14:51:26 +02:00
Sebastian Ullrich
4517c518c8 doc: fix max precedence 2021-04-07 09:20:08 +02:00
Leonardo de Moura
487bcaaf2b chore: remove dead coe 2021-04-06 19:11:59 -07:00
Leonardo de Moura
c1b39afacc chore: update stage0 2021-04-06 19:07:05 -07:00
Leonardo de Moura
70e943ea07 chore: update stage0 2021-04-06 19:04:02 -07:00
Leonardo de Moura
ca314f1aa4 refactor: add helper functions for match syntax elaborator 2021-04-06 19:02:03 -07:00
Sebastian Ullrich
56d191b831 doc: quickstart: formatting 2021-04-06 18:03:58 +02:00
Sebastian Ullrich
ae9e608f98 doc: add quickstart to SUMMARY 2021-04-06 17:48:28 +02:00
Sebastian Ullrich
dcfd6f4873 doc: quickstart 2021-04-06 17:34:01 +02:00
Sebastian Ullrich
3438f425f1 feat: leanpkg init: emit lean_version 2021-04-06 14:38:17 +02:00
Sebastian Ullrich
ad460c84ce chore: Nix: allow editing src/Leanpkg 2021-04-06 14:38:00 +02:00
Sebastian Ullrich
11e2243c9a fix: leanpkg version warning 2021-04-06 14:20:37 +02:00
Leonardo de Moura
9b0c054258 test: auto completion 2021-04-05 20:45:04 -07:00
Leonardo de Moura
4e99336d45 chore: update stage0 2021-04-05 20:01:28 -07:00
Leonardo de Moura
803161d9fc fix: propagate expected type 2021-04-05 20:00:05 -07:00
Leonardo de Moura
3ccd992dad feat: elaborate auxiliary completion node 2021-04-05 19:07:39 -07:00
Leonardo de Moura
06b67f4523 chore: update stage0 2021-04-05 18:53:42 -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
5c838c57f1 chore: disable special support for Syntax.missing at isNodeOf'
It didn't help with the problem I was having, but we talked about
customizing this behavior in the past. So, I will leave the function
here because it is convenient for trying experiments without having to
modify `Quotation.lean` and `update-stage0`
2021-04-05 18:38:58 -07:00
Leonardo de Moura
9d38309781 chore: update stage0 2021-04-05 18:38:58 -07:00
Leonardo de Moura
f9d5c4fc7c chore: update stage0 2021-04-05 18:38:57 -07:00
Leonardo de Moura
9fa89a73df feat: add helper functions for syntax match
Motivation: improve error recovery.
2021-04-05 18:38:57 -07:00
Leonardo de Moura
f13bdd6869 fix: error recovery at sepBy combinator 2021-04-05 18:38:57 -07:00
Leonardo de Moura
474ee644d7 chore: update stage0 2021-04-05 18:38:57 -07:00
Sebastian Ullrich
e863376be1 chore: simplify tests 2021-04-05 22:01:56 +02:00
Leonardo de Moura
fbd6adaf21 chore: fix tests 2021-04-05 12:35:52 -07:00
Leonardo de Moura
fb38955be2 feat: improve command parser error recovery
After a parser error in a command, we are "swallowing" all command
parsing errors until a command was succesfully parsed.
This was producing counterintuitive behavior in the IDEs.
2021-04-05 12:31:33 -07:00
Leonardo de Moura
383e32937e test: completion 2021-04-05 12:01:58 -07:00
Leonardo de Moura
d6af843683 chore: remove completion auxiliary parser 2021-04-05 11:26:13 -07:00
Leonardo de Moura
b1b645f5d7 chore: display expected type 2021-04-05 10:29:32 -07:00
Leonardo de Moura
19fcd518bf chore: fix syntax 2021-04-05 07:16:59 -07:00
Leonardo de Moura
6f1eaa96f1 chore: update stage0 2021-04-05 07:12:42 -07:00
Leonardo de Moura
e6dec2dd79 feat: don't allow whitespaces between . and field name 2021-04-05 07:11:14 -07:00
François G. Dorais
9949aa653e feat: add missing simp lemmas for <-> 2021-04-05 06:41:39 -07:00