[antlr-interest] mparser - a MATLAB grammar in ANTLR

David Wingate wingated at MIT.EDU
Thu Sep 1 16:00:10 PDT 2011


Hello, all --

I've recently been developing a matlab grammar using ANTLR.  It's
polished enough now for my use, so I thought I'd post it to the
list (I've seen other people interested in such a thing).

You can download it at:

   http://www.mit.edu/~wingated/code/mparser_0.1.tar.gz

The grammar supports C and Java language back-ends.  In addition to the
grammar itself, the package includes a MEX interface so that you can
parse matlab code from within matlab itself.  The result is a deeply
nested set of matlab structures representing the AST (which I use to
do source code transformations).

It's not perfect - matlab turns out to be surprisingly hard to parse
(due to lexing ambiguities and matlab's use of syntactically significant
whitespace) but I think I've got most of it right.  I'll follow-up with
a few technical questions to this list to see if I can finish it off
The Right Way, but for now, well... release early, release often.

Any comments / feedback welcome.

I have to say: using ANTLR for this project was definitely the right
choice.  Great work!

		-- David

-- 
David Wingate     | Computational Cognitive Science Group
wingated at mit.edu  |   Brain and Cognitive Sciences
(617) 324-2894    | Stochastic Systems Group
46-4053H BCS      |   Laboratory for Information and Decision Systems


More information about the antlr-interest mailing list