mparser

A matlab lexer and parser written with ANTLR, with a mex interface.
1K Downloads
Updated 1 Sep 2011

View License

This is a MATLAB lexer and parser written using ANTLR. The goal of
this package is to provide a way to parse MATLAB code from within
MATLAB, and to be able to do source code translations on the resulting
AST.

The main workhorse of this package is "mparser", a MEX file which
accepts either a string or a filename and parses it into a deeply
nested set of MATLAB structures representing an AST. These can
examined and manipulated from within MATLAB.

Includes a variety of other tools to parse and examine matlab code.

While I have made every effort to be as exact as I can, there are
still a few differences between this grammar and the "true" MATLAB
grammar. Most of these you will never notice, but there are a few
that are significant:

* The transpose operator ' is not supported (due to lexing confusion
with the single quotes used in string constants).

* Constant matrices and cells must have individual elements separated
by a comma.

* Block comments are not supported.

For others, please see the comments in matlab.g
Hopefully, future versions will remedy this.

Cite As

David Wingate (2026). mparser (https://www.mathworks.com/matlabcentral/fileexchange/32769-mparser), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Version Published Release Notes
1.0.0.0