Compiler projects fall 2015
EDAN70: Project in Computer Science
Bug Detection through Static Analysis
Ella Eriksson and Zimon Kuhs
Abstract:
This paper describes a static code analyser for Java code implemented with the ExtendJ compiler and JastAdd, a Reference Attribute Grammar (RAG) system for Java. Our tool implements some of the analyses implemented by another static analysis tool called ErrorProne. We investigate the efficacy of using aspect-oriented programming with attribute grammars compared to traditional Java compiler coding patterns, like visitors, and what advantages and disadvantages compiler implementation with a declarative coding approach might have over a traditional, imperative approach. We found that our static analysis tool implements comparable analyses using fewer lines of code.
(paper)
(code)
Xtext language-based editor
Mikael Johnsson and Alexander Olsson
Abstract:
How easy is it to make an Eclipse like interactive editor for a DSL, Domain Specific Language, using Xtext? How simple is it to make syntax validation analysis using Xtext and how does that help the user to learn and write program for the language. This report also look at the editor functions, like open new domain specific editor windows and create an I/O console that is done using other frameworks.
(paper)
Viability of extending parser-generator frameworks for layout-sensitive languages
Moritz Kobler
Abstract:
While building parsers has become much easier in the last decades due to the development of tools that allow the generation of both scanners and parsers, such tools are still lacking if one is considering developing layout-sensitive languages. Existing parser generators such as Beaver often have rather simple and easy to produce language specifications as input. Building a parser for layout-sensitive grammars on the other hand requires a lot of manual methods specific to the grammar. The reason for this dichotomy is partly the general predominance of research into context-free grammars.
There are languages currently in use that incorporate layout-sensitive syntax, such as Python, Haskell or occam. At the same time and more importantly there are also legitimate applications of layout-sensitivity including enforcement of the source code's readabilty as well as establishing parallelism between source code and program output. This paper discusses layout-sensitivity, its uses and usefulness and further argues that it is possible to build tools that will enable users to define their own layout-sensitive languages. Specifically, a first step towards facilitating the development of layout-sensitive languages is taken by implementing parsers for different languages using a decorator-approach on top of already existing tools: a preprocessor is interposed between the scanning- and parsing-phases in order to handle layout-sensitivity.
(paper)
(code)
CUP parser generator for JastAdd
Felix Åkerlund and Ragnar Mellbin
Abstract:
We have extended a parser specification preprocessor called JastAddParser to support the Construction of Useful Parsers (CUP) parser generator as a backend in addition to the Beaver parser generator, which previously was the only available option.
In the process of implementing CUP support we also modularized the pre-processor to make it easier to support additional generators in the future. This will make JastAddParser less dependent on the continued support and development of Beaver. It is also interesting to see how a CUP-generated parser performs compared to one built by Beaver.
We encountered several difficulties during the processes, but produced a implementation with partial CUP support.
(paper)
Extending ExtendJ with CUP2 Parser Support
Karl Rikte
Abstract:
JastAdd is a project developed at the CS departement of Lund University to add easy AOP (Aspect Oriented Programming) to the Java language, which is useful for AST generation in compilers. Many projects that use JastAdd also use the Beaver parser.
This paper aims to address how to use alternate parsers with JastAdd projects. It focuses - in particular - on adding CUP2 parser support to ExtendJ, a compiler for the Java language, written in Java, using JastAdd.
Different methods to implement additional parsers support were investigated, and the approach involving the least refactoring was taken. A parser grammar translator program, for easy CUP2 integration with JastAdd projects that use Beaver, has been developed.
Performance and features evaluation has been conducted comparing the Beaver parser to CUP2.
(paper)
(code)
Extending Simplic with an LLVM backend
Johan Forss Lasson and Alexander Åhlander
Abstract:
In this brief article we detail our method for designing an LLVM back end for an ad hoc C-like language known as SimpliC. We outline the features of the language and the extensions to it which we have made. We also give some background on LLVM and the closely related topic of LLVM-IR. The main focus of the article is on how we have solved the different challenges which we came across while implementing the back end, mainly related to allocating memory for structs, using SSA-form variables in an efficient way, and using C-functions in LLVM-IR code. We also compare the performance of our implementation to that of others.
(paper)
LLVM Code Generation for SimpliC
Johan Henriksson
Abstract:
This paper briefly describes the process of extending a simple compiler implemented in a previous course with new language constructs and modifying it to output intermediate code for the LLVM compiler infrastructure instead of x86 assembly. This allows us to take advantage of features like built-in machine code optimizations and the ability to generate assembly code for multiple platforms. Advantages and disadvantages of using LLVM as a compiler framework will also be discussed.
(paper)
Extending a Small Language with a Java Bytecode Back End
Philip Mårtensson and Elliot Jalgard
Abstract:
A simple language called SimpliC with only the core constructs from the C language and an x86 back end had been implemented in a previous course. This project set out to extend this language with new language constructs such as structs, global variables and more data types. Another new addition to the language was a back end for generating Java bytecode runnable in the Java Virtual Machine. The result was compared in terms of execution speed with another back end implementation using LLVM for a similar SimpliC language and corresponding extensions developed by two other groups.
(paper)
LLVM as optimizer and compiler backend
Valdemar Roxling
Abstract:
New programming languages often bring new ideas and tools to the programmer to make certain tasks easier to implement and speed up development. The one thing that many new languages fail to improve is performance, but with some relatively simple backend changes the compiler can use well known and good algorithms to achieve a lot in terms of code optimizations and speed-up.
In this article I have evaluated a backend exchange of an existing small language called SimpliC to generate to the intermediate language LLVM-IR 1. This makes SimpliC work on any platform and operating system supporting LLVM, and I can make use of already existing code optimizers. In addition to performance measurements I have also extended my language with an additional high level construct, nested functions, not natively supported by LLVM.
(paper)
Type inference in Dart
Malte Johansson and Mikel Lindholm
Abstract:
This report describes the implementation of a type inference tool called Minimal Dart Checker for the programming language Dart. The tool helps the programmer to statically check the runtime compatibility of types for variables, including type inference with control flow analysis. The tool was built using JastAdd.
(paper) (code)
Type inference for Go
Emin Gigovic and Philip Malmros
Abstract:
Automatic deduction of a data type from a given expression is in programming referred to as type inference. How advanced the type inference varies between languages, it can go from being a ”nice to have” feature, to being a core part of the language. A subset of the statically typed language Go was implemented using JastAdd, with focus on type inference. By automated tests and comparison of how well type inference works in other languages, the subset was evaluated in a primarily qualitative manner.
(paper) (code)