Hi, there are different options. A lot of people use the lexer and color text depending on token it was recognized as. You can also you the AST for some extra parsing context to color the text. Unfortunately I am not aware of any thrown-in-your-grammar-and-color-defs-and-get-a-complete-syntax-coloring-autocompleting-swing-editor deal. We needed this as well and we did this work ourselves. I know Jim Idle did some things for Visual Studio. There is a jEdit syntaxhighlighting Textcomponent available (stand alone) which may make the task for coloring easier for you.
Also I recently discovered Xtext which automates this task for you but only for Eclipse; it is built upon ANTLR, but they have their own grammar language; it seems to me you cannot reuse your existing ANTLR grammar. Manual Implementation notes. For syntax coloring I used the token stream to get the character positions (start, stop) to mark text parts in different colors. For auto-completion I used a generic error handler which does some magic on the stack trace to find out the context of the parser and the next possible tokens via the follow set (ANTLR provides support to calculate this, very nice). BR, Paul ext [email protected] schrieb: > Helllo!! > > I think this is an old topic, but looking at the list I haven't found a > clear answer to the problem. I am trying to do a system that opens in a > swing panel an specific type file, which follows my specific grammar and > allows its editing. > Hence, I want to add syntax-highlighting and also auto completion to the > file (both in the editing and in the only reading), But also I should show > the syntax tree. > > I have my ANTLR grammar running (pluto.g) and tested with current output > as a flat AST tree. But I am not entirely sure what to do next. > > My first option is to specify as output templates and use directly from > the parser grammar StringTemplate with the output specifying the colors, > font, etc in a kind of HTML similar code and later plug-in in the swing > panel > Second option, is to create a Parser Tree and later on, use the templates > Third, forget the parser and just use the lexer???? > > The problem is that the final goal of the system is to create SQL queries > to insert/modify in a DB the information that contains the grammar. > > Any outputs are welcome, thanks > > > > Nieves Salor Moral > ------------------------------------------------------------------------ > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
