[antlr-interest] ANTLR for syntax highlighting and word completion

Sam Harwell sharwell at pixelminegames.com
Sun Feb 1 19:39:47 PST 2009


I have many posts on my blog about this subject. Here's the link to my blog, and a link to the first major post specific to using ANTLR in an IDE. The ANTLR-based highlighters we're using are nowhere near as slow as Eclipse. However, there are many places where IDE performance imposed "interesting" constraints on grammar designs, and we had to take care of them on a case-by-case basis.

http://blog.280z28.org/

http://blog.280z28.org/archives/2008/10/21/

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Paul Bouché
Sent: Sunday, February 01, 2009 6:58 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] ANTLR for syntax highlighting and word completion

Hi,

I am about to build a new parser for our rules language replacing a hand 
written parser. So I want to show the hand-written-parser disciples what 
ANTLR is all about ;-)

Anyway, I have read on this list that someone planned an integrated 
environment for doing just that - where can I find it?

I have heard that Eclipse uses ANTLR internally for its highlighting and 
word completion features - can you confirm this?
I have read somewhere else that it uses the Jikes Parser Generator 
(jikespg).

Actually I have already completed a preliminary version of a grammer 
which does syntax highlighting by providing a list of marker objects 
where each marker is created of a token has sucessfully been recognized 
with the start and end position, i.e.:
@members {
            }
            public void marker(String kind) {
                   // get last delivered token - I thought my I idea 
doing this is pretty slick
                    Token token = input.LT(-1);
                    if (token instanceof CommonToken) {
                        CommonToken ct = (CommonToken) token;
                        Marker marker =                        
                            new Marker(ct.getStartIndex(),
                                       ct.getStopIndex() - 
ct.getStartIndex() + 1,
                                       kind);
                        marks.add(marker);                       
                    }
            }
}

statment :
    JUMP { marker("Keyword"); }  destination  { marker("Variable"); }
    ;

destination :    NAME | VARIABLE    ;

...
I would enrich this grammar with completion actions, in the case of 
exceptions and being in "completion mode". It also took me so fiddling 
to find out how make ANTLR recover the way I want (I should've read the 
book first ;-)).

A co-worder suggested constructing an AST first (cleaner parser and more 
flexibilty), also Terence does so in the book and in the AST parser then 
do the things I'd like. The deal is that my predecessor did this for 
another project and the Tree parser is 7 times slower than the previous 
non-AST parser. Do you have any suggestion what to avoid so that there 
won't be a significant loss of speed? This is especially important for 
syntax highlighting because the GUI user must not be hindered by the 
highlighting process.

Any other comments or suggestions on syntax highlighting or word 
completion with ANTLR are highly appreciated!

Have a great day,
Paul

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