[antlr-interest] very basic question

Loring Craymer craymer at warpiv.com
Fri Jun 23 21:28:02 PDT 2006


Answers to questions below.  BTW, why use Python as a target language?  The
Python interpreter is pretty slow, so you will probably lose performance.
If the problem is that you do not have a Matlab license, then Scilab should
do what you want.  Otherwise, it might make more sense to translate the
Matlab code to C++ and use SWIG to interface to Python.

--Loring

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Mathew Yeates
> Sent: Friday, June 23, 2006 8:31 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] very basic question
> 
> Hi
> I want to translate some Matlab code to Python. I know very little about
> the subject (some yacc and lex) but I came across the ANTLR site and
> this looks like it might be a good approach.
> 
> I have some very basic questions.
> 1) I see there is a grammar for Python 2.3. Is there one for Python 2.4?

If not, it would be easy to generate--the python parser grammar was machine
generated and tweaked by hand.  However, I suspect that there are no grammar
differences between 2.3 and 2.4.

> 2) Do I need both the Python and Matlab grammars?

No, just the Matlab grammar.  For output, check out StringTemplate (same
server as antlr.org, but at stringtemplate.org).

> 3) Is there a Matlab grammar somewhere? If not, how do I generate it? As
> a side note, I have .y .l files from Octave which should be very similar
> to Matlab

Check out the Scilab sources (http://scilabsoft.inria.fr/).  The conversion
tools probably have a Matlab grammar, likely a lex/yacc one.

> 4) Then what? I looked at several tutorials and see how to parse the
> input but I havent seen a description of doing the translation.

Check out some of the grammars on the ANTLR site; the ANTLR GNU C translator
might be a good place to start.

> 
> Any help is appreciated!
> Mathew



More information about the antlr-interest mailing list