matlabgrammarlexermatlab-deploymentformal-languages

Where can I find a formal grammar for MATLAB?


I would like to write a lexer generator to convert a basic subset of the MATLAB language to C#, C++, etc. To help me do this, I would like to find a document containing the formal grammar for MATLAB. Having spent a bit of time investigating this, it seems that Mathworks do not provide one.

Does anyone know where I could find such a document?


Solution

  • Excellent opportunity to write your own formal grammar :)

    If you should choose to write the grammer your self, I can recommend BNFC which can take a formal BNF grammar and construct data structures and lexers/parsers for a couple of target languages (C/C++, C#, Java, Haskell etc.). This would save you a lot of time and let you focus on formulating the grammar, and then get right to implementing the converter in your language of preference.

    If nothing else, the link to BNFC contains some help and pointers on how to formulate a BNF grammar. Best of luck!