[antlr-interest] Re: ANTLR+Eclipse

Richard Clark rd_clark at sbcglobal.net
Thu Aug 5 21:21:10 PDT 2004


--- In antlr-interest at yahoogroups.com, "Tiller, Michael \(M.M.\)" <mtiller at f...> wrote:
> I was wondering if anybody had ever tried to use ANTLR to implement a
> scanner in Eclipse. [snip]

I've gotten a great start on this yesterday and today. In particular, I was able to replace the 
rule-based partition scanner with one driven by an ANTLR-generated lexer. It's still going 
to need some work to be more robust in the face of lexing errors (e.g. illegal characters in 
the input), but I'm working on it. :)

> It seems like all that would be required would be to interface the lexer
> to the Eclipse representation of a document (so you could scan the
> characters in the document) ...

Done. I had to create my own plug-compatible replacement for the InputBuffer class (as 
indicated by yesterday's post re: in-memory I/O.) I also created a "lexer token" wrapper to 
bridge between ANTLR's tokens and Eclipse's IToken. 

> ... and then somehow tuck the results away so
> that subsequent calls to specialized token scanners, etc. wouldn't even
> look at the document but would instead just return information based on
> walking the AST.

A syntax-based editor would need both the low-level lexer tokens *and* the AST as the 
AST is (by definition) distilled and re-organized from the tokens. The AST could drive the 
Outline panel, provide syntax checking and refactoring support, etc.

Once I have the lexer-partitioning interface working robustly, even with bad input, I can 
move on and start experimenting binding in the AST. Still, it's pretty cool to have 
automatic code coloration running off an ANTLR lexer with only about 8 hours of work.

 ...Richard




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list