[antlr-interest] Newbie Questions

Wincent Colaiuta win at wincent.com
Sat Jul 14 03:16:16 PDT 2007


El 14/7/2007, a las 11:21, Chua Chee Seng escribió:

> Hi all,
>
> I am newbie in Antlr.  I am trying to write a traslator which will  
> take a
> text file which contains regular text and text that are 'mark-up' with
> \@text at .  The translator will translate text mark-up with '\@..@'  
> to some
> other texts.  Is Antlr the right tool to create parser and  
> translator for
> this kind of mark-up language?  If yes, how the grammar should  
> looked like?
>
> Please kindly advice, thanks in advance.  :-)
>
> Best Regards,
> Chee Seng

I don't know if it is the "right" tool for the job, but I have used  
it to do a similar job as my first real project in ANTLR (a wikitext- 
to-HTML translator). Your scenario (mostly "dross" with some  
interspersed markup) is probably best handled by a filtering lexer.  
In my case I then hand-coded my parser rather than using an ANTLR- 
generated one, partly because of issues ANTLR has with combining  
filtering lexers with parser (see <http://www.antlr.org/ 
pipermail/antlr-interest/2007-June/021243.html>), and partly because  
I wanted very specific error-recovery behaviour in the parser that I  
found to be very difficult to get using vanilla ANTLR parser.

So I would recommend that you start by searching the list archives  
for information on filtering lexers, and also some threads on how to  
parse wiki text. Jim Idle posted a sample grammar for this, in fact  
(<http://www.antlr.org/pipermail/antlr-interest/2007-June/ 
021177.html>), and although it wasn't right for my needs it might  
give you some ideas.

Cheers,
Wincent




More information about the antlr-interest mailing list