The Design and Implementation of a Parser and Scanner for the MATLAB Language in the MATCH Compiler

Pramod G. Joisha, Abhay Kanhere, Prithviraj Banerjee, U. Nagaraj Shenoy and Alok Choudhary

Abstract

In this report, we present the design and implementation of the MATCH compiler front-end. We discuss in detail both the indigenously designed grammar responsible for syntax analysis as well as the lexical specification that complements the grammar. In the course of our attempts to emulate MATLAB's syntax, we were able to unravel certain key issues relating to its syntax, such as the parsing of command-form function invocations and how the single quote character is differently construed depending on the context. The front-end effects a conversion of the original source to an intermediate form in which statements are represented as abstract syntax trees and the flow of control between statements by a control-flow graph. All subsequent compiler passes work on this intermediate representation.

Gzipped Postscript version of the paper