[antlr-interest] automated completion - choosing matching productions and the next token

Terence Parr parrt at cs.usfca.edu
Sat Jun 14 00:19:05 PDT 2008


I'm supposed to be working on book while traveling but spent a few  
hours yesterday thinking about how useful NFAs of the grammar would  
be at runtime.  As we parse, I could update a ptr into the NFA and  
keep a stack of rulenames etc...  At any moment, one could ask the  
NFA for the set of next valid tokens.  This would make the generated  
code simpler as well since I wouldn't have to precompute all those  
damn bitsets for FOLLOWs (error handling sets).

Would be great for autocompletion and other stuff.

if i could do some lookahead prediction with it, i could also avoid  
generating synpreds as separate classes etc...

I'll try to put this together for 3.2

Ter
On Jun 14, 2008, at 12:57 AM, Doucette, Charles wrote:

> I am working on an editor for a language.
> I have a grammar definition for a parser that builds a custom AST  
> tree (not a standard Antlr AST tree).
> The editor already uses the parser to  automatically flag syntax  
> errors.
>
> Is there any way to automatically determine
> a) the current production
> b) the current token based on the production
> c) semantically choose the appropriate completions based on a) & b)  
> above
>
> The Eclipse Java editor and JDT do this all already, so I know the  
> technology exists.
> What I don't know is if it is based on fully automated parser  
> technology (like from Antlr) or if it is based on simple heuristics
> (like looking for an identifier after a "." or "=").
>
> Thanks,
> Chuck
>
> Charles E. Doucette ·  617-399-1122 ·  Vaultus Mobile Technologies,  
> 263 Summer St., Boston, MA 02210 ·  http://www.vaultus.com
>



More information about the antlr-interest mailing list