Can ANTLR answer the question: What tokens are valid next?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Luke_Usherwood
Posted On:   Friday, June 4, 2004 07:32 AM

I'm wondering if an ANTLR grammer can be exploited in some way to be able to answer the question "What tokens are valid next?" The purpose of this would be to provide intelligent suggestions for a code-completion mechanism. I already have a mechanism in place for building suggestion lists for identifiers, but at the moment every single keyword in my language has to be added to the suggestion list. (This is far from ideal, as there are a lot of keywords!). The solution I was thinking about is to parse the text from an editor up to the cursor position, and then interrogate the state of the ANTLR parser in some way to answer this question. But looking at the antlr-generated code, it doesn't look like this    More>>

I'm wondering if an ANTLR grammer can be exploited in some way to be able to answer the question "What tokens are valid next?"


The purpose of this would be to provide intelligent suggestions for a code-completion mechanism. I already have a mechanism in place for building suggestion lists for identifiers, but at the moment every single keyword in my language has to be added to the suggestion list. (This is far from ideal, as there are a lot of keywords!).


The solution I was thinking about is to parse the text from an editor up to the cursor position, and then interrogate the state of the ANTLR parser in some way to answer this question. But looking at the antlr-generated code, it doesn't look like this sort of thing is possible.


Has anyone looked into this kind of problem before?

   <<Less
About | Sitemap | Contact