question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to get all possible next tokens for autocompletion use

See original GitHub issue

Bruno LETRESTE points out:

i use yours getExpectedToken after i move to position in my algorithm my algorithm check the tokens and try to find the real path (in ATN tree) it stock the potential terminate for solve for exemple (and add potential to expected token)

expr : '(' expr ')'
       | expr '+' expr
       | ID
       ;

for exemple in this case, if i have ( ID I get expected token return + but it should have ) as well.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:19 (13 by maintainers)

github_iconTop GitHub Comments

6reactions
mike-lischkecommented, May 31, 2018

Ah, good you reminded me. The C++ implementation is on Github since a few weeks already. However, there’s no readme or other document in that repo for this code. However, I have a port (or rather a parallel development) of this idea written in Typescript (and there are ports of that code to Kotlin and Java). And this repo also contains some documentation how to configure and use the engine. Let’s discuss there if you have any questions.

2reactions
kaby76commented, Jan 10, 2020

I’ve noticed with Mike Lischke’s implementation that it does not compute the lookahead sets correctly in some situations. In particular, for Antlr grammars, if I want the lookahead set after a parser rule semicolon, I get an incomplete set that also includes epsilon but should not. Starting with Mike’s implementation, and Parr’s LL(*) paper, I derived a similar algorithm (http://codinggorilla.com/?p=2449) and have C# implementations for code completion in an LSP server and for error reporting in a Net Core Antlr “Hello World” template (https://github.com/kaby76/Antlr4BuildTasks/blob/master/Templates/templates/AntlrCAProject/LASets.cs). Note, the design is recursive and makes a call per an edge/token match, so I don’t doubt stack overflow issues in construction of a parse. One step at a time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

H98: Using HTML 5.2 autocomplete attributes
The technique works by adding the appropriate autocomplete token to each form field on the form to make the identified inputs Programmatically Determinable....
Read more >
Antlr3 next available tokens when parsing incomplete statement
Sorry to say this but: don't use a parser directly for auto completion. There are several reasons why this won't work as you...
Read more >
HTML attribute: autocomplete - MDN Web Docs
The HTML autocomplete attribute lets web developers specify what if any permission the user agent has to provide automated assistance in ...
Read more >
Building autocompletion for an ANTLR parser - Google Groups
I call this part "syntactic autocompletion" and it works for all kinds of tokens but identifiers. I wrote the algorithm once and I...
Read more >
CodeFill: Multi-token Code Completion by Jointly Learning ...
CodeFill surpasses all baselines in single token predic- ... tocompletion systems also take into account past completions [43].
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found