[antlr-interest] yacc 2 atlr

Loring Craymer craymer at warpiv.com
Mon Jun 26 20:12:27 PDT 2006


Mathew--

I can't help with the lex files; those you will probably have to do by hand,
but that should not be difficult--Matlab is pretty regular and should not
have a complex lexer.  (It would not be that difficult to write a lex to
ANTLR translator; I just haven't done that.)  I can help with yacc; I have a
bison/yacc to antlr translator that I put together to convert an Ada
grammar; I'll post it to the ANTLR site a little later this
evening--somehow, I think that I should put a README file together first.

You will find that the converted grammars tend to have quite a bit of left
recursion that results from BNF limitations (no ()* or ()+).  When you run
them through ANTLR you will get complaints about left recursion; refactor
the offending rules to use loops and you should converge on a working
grammar quickly.  The convention seems to be to name such rules with an _s
so that you see definitions like

foo_s :  foo_s foo ;

which should be rewritten as

foo_s : (foo)+ ;

--Loring

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Mathew Yeates
> Sent: Monday, June 26, 2006 7:39 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] yacc 2 atlr
> 
> I have yacc and lex files for a Matlab clone. Is there an article
> somewhere that describes how to translate these into a grammar?
> 
> Mathew



More information about the antlr-interest mailing list