Parsing and semantic analysis of a domain specific language

A domain specific language (DSL) is a computer programming language of limited expressiveness focused on a particular domain. A DSL offers programmers a high level abstraction for them to express their algorithms. In engineering and the sciences, MATLAB is a commonly used domain specific language to...

Full description

Saved in:
Bibliographic Details
Main Author: Qin, Gemeng
Other Authors: Stephen John Turner
Format: Final Year Project
Language:English
Published: 2014
Subjects:
Online Access:http://hdl.handle.net/10356/59990
Tags: Add Tag
No Tags, Be the first to tag this record!
Institution: Nanyang Technological University
Language: English
Description
Summary:A domain specific language (DSL) is a computer programming language of limited expressiveness focused on a particular domain. A DSL offers programmers a high level abstraction for them to express their algorithms. In engineering and the sciences, MATLAB is a commonly used domain specific language to quickly prototype algorithms owing to the dynamic nature of the language and its ease of use. However, the dynamic nature of the language comes with additional costs, such as overheads due to late binding. The front-end for MATLAB was developed in this project to translate MATLAB to the intermediate language so that MATLAB can be translated into a static programming language such as C/C++ to reduce the overheads and other costs of the dynamic feature. In this project, stencil computation in MATLAB is analysed as a case study. Since all data types in MATLAB is in a form of an array, the analysis of arrays were performed in the implementation. This report presents how a parser was implemented to parse the MATLAB language and how the constructs are represented internally using an intermediate representation. Certain semantic analysis were also performed to ensure that the user-written codes are well-formed as well as to infer type information from the source code. This involves processes such as type inference of variables in MATLAB, size inference of array and error checking of uninitialized variables, and array type or shape mismatch.