[antlr-interest] Syntax highlighting : need some advice

Sam Harwell sam at tunnelvisionlabs.com
Mon Apr 9 11:17:59 PDT 2012


You should be aware from the start that you're entering an area with sparse
documentation, much of which suffers from:

* Incomplete (works for some examples but leaves you hanging when you want
to do something more)
* Outdated (applies to Visual Studio 2008 or earlier - Visual Studio 2010
supports this but also offers a much more powerful new model that is
preferable in pretty much every way).
* Incorrect (violates best practices and/or exemplifies things I've come to
realize are bad ideas)

I also have to point out the following regarding your message below:

* When it comes to this task, the only things "simple" about the Java
language is it doesn't require a preprocessor and it doesn't have any
context-sensitive keywords.
* One extension for Java support already exists, so if you're just looking
for something to use it may save you some time:
http://visualstudiogallery.msdn.microsoft.com/bc561769-36ff-4a40-9504-e266e8
706f93

Here are some resources to get you started:

[1] Diff Classifier example. I haven't looked at the code, but based on the
description it uses the new Visual Studio 2010 APIs which I recommend unless
you absolutely must for some reason support 2008 and/or 2005.

[2] DiveDeeper's blog. This is a mix of many VSX topics.

[3] Topics tagged "Programming" on my blog. It's a mix of various topics
from Visual Studio 2008 and 2010, plus a bit of information about using
ANTLR 3 as part of your extension.


[1] http://code.msdn.microsoft.com/windowsdesktop/Diff-Classifier-e87ed723
[2] http://dotneteers.net/blogs/divedeeper/default.aspx
[3] http://blog.280z28.org/archives/category/programming/


--
Sam Harwell
Owner, Lead Developer
http://tunnelvisionlabs.com


-----Original Message-----
From: forumer at smartmobili.com [mailto:forumer at smartmobili.com] 
Sent: Sunday, April 08, 2012 7:14 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Syntax highlighting : need some advice

Hi,

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 ?



Thanks

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list