[antlr-interest] parsing MATLAB - 6.0/7.0 files

rahul rahulkharche at gmail.com
Wed May 18 04:42:19 PDT 2005


Hi

   I am looking at parsing MATLAB files using ANTLR. The earlier
version of MATLAB (6.x) had a file structure that looked like

function x = A(p1,p2)
...

function y = B(p3)
...

function z = C(p4)
...

with implicit ends to the function bodies. The new version 7.x has
introduced the concept of nested functions, much like PASCAL.

function x = A(p1, p2)
...
   function y = B(p3)
   ...
      function z = C(p4)
      ...
      end
   ...
   end
...
end

function D(p5)

...
end

For the reason of compatibility MATLAB retains both these file
structures and either can be used, but not mixed.

Is it possible to parse a file not knowing the format and using one
single grammar?

Or do I need to make a quick initial run through a file first to
detect the syntax and then invoke the parser to follow one of the
formats.

If one sigle grammar is possible would it be efficient, say if I
considered the use of syntactic predicates?

Thanks,
Rahul


More information about the antlr-interest mailing list