/2020_08_NMN

Primary LanguageTeXGNU General Public License v3.0GPL-3.0

LINVAST - Language-INVariant AST library
Extending LINVAST with new programming language - Java

Student project on course Software verification, Master Degree Studies, University of Belgrade, Faculty of Mathematics

About LINVAST

LINVAST is a set of libraries which provide common AST API for many programming languages by abstracting ANTLR parse trees. Currently, the main focus of the project is the imperative programming paradigm, with supported languages: C, Lua.

Motivation and project description

There are many programming languages out there and, even though their syntax might be different, they often derive from or use certain universal programming concepts. We also call that a way of writing code or, more commonly, a programming paradigm. The motivation for LINVAST came from the inability to find a shared API for every programming language that is a part of a procedural paradigm. LINVAST aims to create a common abstraction for imperative (but also procedural, OO, script and, through a few concepts, functional) programming paradigm so that it is possible to view many different programming languages on the same level of abstraction.

LINVAST can theoretically work with any programming language as long as the adapter for that language is written (hence, Language Invariant). Adapters (or, in further text, Builders) serve as an intermediary between ANTLR parse trees and language-invariant ASTs. Builders are used to generate AST from a parse tree and they are implemented differently for every programming language due to native differences in parse trees. LINVAST provides intuitive API for generating and traversing generated ASTs and also provides already implemented visitors for common AST operations such as expression evaluation.

LINVAST was made as a proof of concept for my MSc thesis (Semantic comparison of structurally similar imperative code segments) but has grown with aim to become fully operational and manageable long-term. LINVAST can be used as a tool to generate serialized AST in JSON, and provides intuitive API which is used in many standalone programs which use LINVAST API to visualize or compare generated ASTs.

About the project

The purpose of this project was to expand original LINVAST project with Builders and to generate AST for language Java. In order to extend LINVAST with new language, you should create (or use already made) ANTLR4 grammar files, create lexer and parser for your grammar, and implement the Builder for your language. The main students' task in the project was designing, implementing and testing the Builder for Java. The task was divided in 4 parts, each covering some consistent part of the grammar: Types, Declarations, Functions and Expressions.

Java is the first Object-oriented programming language supported by LINVAST.

Languages and technologies used

Contact