[antlr-interest] syntax highlighting & pretty printing

Sebastian Mies sebastian.mies at gmx.net
Tue Jan 3 02:45:13 PST 2006


Hi Arnulf,

I have worked framework to do syntax highlighning and syntax
checking on the fly. Pretty printing is not included yet.
But you can generate a editor for eclipse in about 30 min.
from an existing ANTLR 3(!) grammar.
As soon as I have finished the proper partitioning algorithms,
I will release it under FreeBSD or GPL.
Ter is also thinking on these points - so its just a matter of time :)

Regards,
Sebastian.

P.S.: Happy new year! Frohes neues Jahr!

AH> Hi there,

AH> have there been any thoughts to include such features directly into
AH> the design of ANTLR?

AH> I never designed a syntax highlighter by myself (just listened to the
AH> discussions in this list), so please forgive obvious statements.

AH> Each time one designs a language, there is usually demand for a 
AH> modern way of editing in the target language. In my understanding the
AH> grammar definition of a language is the right starting point for 
AH> doing SH and PP. What I wanted to have as a user of ANTLR is a common
AH> base - the grammar files - and ANTLR spit out the lexer/parser plus
AH> SH/PP stuff.

AH> So, given a valid ANTLR grammar file, is there an easy way to 
AH> generate token definition files for popular editors like eclipse on the fly?
AH> Maybe ANTLR itself would be the right tool for syntax highlighting,
AH> provided it offers the required interface to, e.g., eclipse (in order
AH> to embed an grammar driven parser into eclipse).

AH> I recognize that this might be hard to do for languages that need 
AH> user code for code books etc, but at least that should work for 
AH> simple grammars.

AH> Concerning pretty printing: What if ANTLR generates string templates
AH> for every rule in the grammar? I'm not too familiar with how 
AH> stringtemplate works, but I think the return value of each rule 
AH> should be a instance of a string template.

AH> So, if one has a rule like:

AH> ifrule : "if" LPAREN boolexpr RPAREN LCURLY stmts RCURLY;

AH> a proper string template might be (remove syntax errors):

AH> ifrule(boolexpr,stmts) ::= <<
AH> if ( $boolexpr$ )
AH> {
AH>         $stmts$
AH> }
 >>>

AH> arnulf





More information about the antlr-interest mailing list