aya-dev
aya-dev copied to clipboard
How to implement completion?
As title. I'm quite unsure how to do this..
We may need to implement aya-prover/aya-prover-proto#508 first because we should be able to provide completions on incomplete programs IMO
But the biggest problem is that our parser currently cannot recover from parse errors like
def test => zero
def a =>
So when vscode is trying to request completions in a, we can do nothing because parser produces no results :(
@imkiva We can just define the syntax better to make these code parse
@imkiva For example, we can make a "definition without body" a type error instead of a parse error
@imkiva For example, we can make a "definition without body" a type error instead of a parse error
This sounds very unlike a type error
@imkiva For example, we can make a "definition without body" a type error instead of a parse error
This sounds very unlike a type error
It can be thrown as a type error and the users would see a syntax error
Btw how does Arend solve this?
Btw how does Arend solve this?
Their JB plugin uses a different parser which is fault-tolerant (JB has a general framework for code completion).
Can we have some fault-tolerant parser?
@ice1000 But this does not cover all cases and we need to change every pass in the compiler every time the syntax compromises.
It seems ANTLR4 can recover: https://www.antlr.org/api/Java/org/antlr/v4/runtime/ANTLRErrorStrategy.html
Can we have some fault-tolerant parser?
Idk if you could reuse GK
It seems ANTLR4 can recover: https://www.antlr.org/api/Java/org/antlr/v4/runtime/ANTLRErrorStrategy.html
Is that easy to adapt in Aya?
It seems ANTLR4 can recover: https://www.antlr.org/api/Java/org/antlr/v4/runtime/ANTLRErrorStrategy.html
Is that easy to adapt in Aya?
It's a little difficult. ANTLR does not have detailed documents on this.
I saw about tree-sitter. Is that any helpful for our case?
@re-xyr It doesn't have a good Java rewrite/binding yet. JetBrains has a JNI-based binding, but I ain't sure if it's open sourced or "good" in any sense.
It seems ANTLR4 can recover: https://www.antlr.org/api/Java/org/antlr/v4/runtime/ANTLRErrorStrategy.html
Is that easy to adapt in Aya?
It's a little difficult. ANTLR does not have detailed documents on this.
org.antlr.v4.runtime.Parser#setErrorHandler(ANTLRErrorStrategy handler)

Quite easy.
Quite easy.
I mean these magic functions not the API


Maybe we can just look at the default implementation
This is what I see. They're heavily documented
I don’t know much about incremental compiling. If we are to offer ide support, are we going to do that anyway? Is ANTLR a capable parser of that? How would we adapt our typechecking process for that?
@re-xyr I have no idea. Probably we should only implement file-level incremental compilation as Agda to avoid the complications
/cc @ShreckYe
Our parsers are decoupled from base module now. Should we introduce a tree-sitter for LSP only?
The problem is that there isn't a reliable tree-sitter implementation for JVM. IIRC fleet uses their own binding, which I consider reliable, but it's not open sourced