Is is possible to use ANTLR to provide lexical/syntax highlighting to, for instance, a swing edit panel?

Antonio Hernandez

Yes it's possible. I've developed an editor with lexical/highlighting using ANTLR. You only have to extend the Default EditorKit class and suite it to your needs. In the class used to display the document (usually a class extending PlainView) just call the lexer passing it the text of a text component. Then call nextToken() until you find an EOF. The only problem is that it may be inefficient because each time you scan a portion of text (usually a line) you have to create an InoutStream which contain that text and change the lexer Input State.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact