[antlr-interest] Re: Error token

Bogdan Mitu bogdan_mt at yahoo.com
Tue Mar 23 08:13:05 PST 2004


Hello Jan,

I wrote the SATC syntax highlight some time ago. ANTLR was not designed for
incomplete source file, as they are while under edit, and generated lexers
are unforgivening with tokens that they don't recognise (I mean, they are
not created at all). 

What I did was to patch the ANTLR JavaCodeGenerator. I attach the patch (it
was ANTLR 2.7.2a1 at that time). My changes are marked with //b>> and //b<<.

If you are reluctant to modify ANTLR files, you can obtain the same result
by post-processing the lexers generated by ANTLR. Or maybe someone can come
up with a simpler idea.

If you use the version from the Yahoo ANTLR group, you might want to try
also a newer version, available on www.antlr.org in the shared files. This
one features an incremental parser for Java (keeps the AST updated while the
source file is edited). 

Cheers,
Bogdan


--- In antlr-interest at yahoogroups.com, "Jan Oetting" <jan.oetting at g...>
wrote:
> Hello,
> I'd like to use satc (Syntax Aware Text Component) With ANTLR.
> satc scannes my grammar every few seconds and if it recognise a token,
> it displays it colored (great feature).
> But if a token is omitted, the text is displayed white (on white
> background).
> So even if I am in an error state for example ("Hello World) without
closing
> "
> I need to get a token back.
> So I need in my Lexer a possibility to define a token, that takes every
text
> if it is not 
> reached by another rule.
> How can I do this?
> If I 
> 1) define REST : (.)* I have thousands of NONDETERMINISMUS and no
guaranties
> that this rule
> ist machted second
> 2) catch the RecognitionException with a Tokenstramfilter, SATC cannot
> operate on the filter, because
> it needs a Charscanner to operate on...
> 3)...another idea?
> 
> Thanks in advance
> Jan Oetting
> 
> -- 
> +++ NEU bei GMX und erstmalig in Deutschland: TÜV-geprüfter Virenschutz
+++
> 100% Virenerkennung nach Wildlist. Infos: http://www.gmx.net/virenschutz

__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

 
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/
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: incomplete_patch.zip
Type: application/zip
Size: 53146 bytes
Desc: incomplete_patch.zip
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20040323/b3c4a6d6/incomplete_patch.zip


More information about the antlr-interest mailing list