[antlr-interest] Parsing Snippets of Code
Raymi
raymi at gmx.ch
Thu Jul 24 13:45:02 PDT 2008
Hi Ana,
thank you for the hint with Pygments. Looks really promising. I'll
certainly give it a try. And: wow, looks like you get your answers quite
fast in this mailing list! I really appreciate all your help.
Nevertheless it still interests me whether it is possible to parse
codesnippets with ANTLR.
Thanks again,
raymi
Ana Nelson schrieb:
> Have you looked at Pygments? It's a flexible and powerful option. It
> has support for several formats besides HTML and you can write your
> own formatters as well as lexers for new languages. (It even
> highlights ANTLR)
>
> Even if you decide Pygments isn't for you, looking at the (python)
> source code would give you a very good idea of what's involved with
> writing your own syntax highlighter and you could then implement this
> in ANTLR. Looking at one of the lexer files for a language you are
> familiar with will give you an idea of what sort of parsing
> granularity is required for good, robust syntax highlighting.
>
>
>
>
> 2008/7/24 Raymi <raymi at gmx.ch>:
>
> Hi,
>
> thanks for your reply. My intention is to build a kind of
> versatile syntax highlighing. It should be able to highlight code
> snippets as well. I am not very pleased with the syntax
> highlighting toolboxes that are available, either they are too
> restricted to some languages or to the output they generate
> (usually HTML). Usually they are also not able to properly format
> the output (e.g. indentation). I think that ANTLR could help me
> with this task.
>
> Since performance is not really that important in this kind of
> application, probably one could just try a brute force approach
> and test all rules until one matches?
>
> Greets,
>
> Raymi
>
> Edwards, Waverly schrieb:
>
> Let me start by saying, I don't know but...
>
> I would think the surrounding information is needed in order
> to make a parse.
> You would have to make assumptions based on context of the
> identifiers. Basically, you would end
> up with a best guess but not necessarily a verifiable parse.
>
> I've desired to write a tool to translate snippets from one
> language to another. It requires an
> intimate knowledge of the source language and the tendencies
> of use. If something like this does
> exist using ANTLR I'd like to study it. I've always found
> this type of tool fascinating.
>
>
> W.
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org
> <mailto:antlr-interest-bounces at antlr.org>
> [mailto:antlr-interest-bounces at antlr.org
> <mailto:antlr-interest-bounces at antlr.org>] On Behalf Of
> Dominik Raymann
> Sent: Thursday, July 24, 2008 8:29 AM
> To: antlr-interest at antlr.org <mailto:antlr-interest at antlr.org>
> Subject: [antlr-interest] Parsing Snippets of Code
>
> Hi there,
>
> it is possible to parse Snippets of Code for a known
> languagewith ANTLR? In the FAQ example
> (http://www.antlr.org/wiki/pages/viewpage.action?pageId=789)
> for example what would I have to do to actually parse the
> given input (that represents a Java method), if I don't know
> whether it is a method, a method body, a class, a variable
> declaration or what else. Is this possible with ANTLR?
>
> Cheers,
>
> raymi
> --
> Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu
> sparen! Ideal für Modem und ISDN:
> http://www.gmx.net/de/go/smartsurfer
>
>
>
More information about the antlr-interest
mailing list