[antlr-interest] Syntax highlighting : need some advice

forumer at smartmobili.com forumer at smartmobili.com
Sun Apr 8 05:13:56 PDT 2012


I would like to create some visual studio plugins to provide syntax 
highlighting (and maybe latter code completion)
for some custom languages. To start with a "simple" language I am using 
the java 1.6 grammar and I would like to know
how can I provide syntax coloration knowing that editor calls a 
function and gives source code line by line.
For instance editor gives the following lines instead of providing the 
entire source code:

* Some comment

package com.foobar.servlets;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.mail.*;
import javax.mail.internet.InternetAddress;

and the first question is how can I parse those lines and know in which 
context I am ?
Is the lexer enough or do I have to use the parser ?
In java 1.6 grammar comments are skipped so how can I change that to 
recognize comments ?
About comments, if I only get a part of the comment like this :


I suppose lexer will throw an exception because it will try to find the 
matching */
so how can I prevent this ?


More information about the antlr-interest mailing list