Superimposing a points-to analysis on the AST
Anton Skorup
Abstract:
This paper presents the implementation of a combined points-to analysis and
rapid type analysis (RTA) for the Java programming language, using the ExtendJ
Java compiler and JastAdd. The goal is to superimpose the points-to analysis
on the abstract syntax tree (AST) while interleaving it with the RTA.
The analysis aims to determine which memory locations a pointer can refer to,
which can be used to identify potential null pointer references.
The implementation leverages JastAdd’s reference attribute grammar to automate
the interleaving of analyses, reducing manual work.
The proof-of-concept demonstrates the feasibility of this approach,
although it currently faces limitations with array dereferences and generic types.
Future work will focus on refining the RTA and evaluating the scalability of the
analysis on larger code bases.
(paper)
(code)
Call Graph Visualization for Visual Studio Code
Anahita Chavan and Jacob Johansson
Abstract:
Understanding how parts within a codebase interact is vital for software development, especially in large and complex systems. This paper introduces an approach to call graph visualization as an integrated extension for Visual Studio Code. Our solution uses a client-server architecture, and leverages the Language Server Protocol, to provide demand-driven call graph generation for Java code. The tool has features such as selective file analysis, expandable nodes, and different depth levels of visualization. We evaluate our approach on simple and complex codebases; the solution has limitations in scalability and language support, which we address with proposed future work.
(paper)
(code)
Projection Boxes in CodeProber
Vera Paulsson and Klara Tjernström
Abstract:
We introduce projection boxes, a live programming feature, into the client-server application CodeProber. CodeProber provides its user with live feedback to visualize and investigate the AST created from the analysis tool. Examples of CodeProber’s use cases are the compiler and program analysis courses at LTH. Our addition of projection boxes extends CodeProber’s liveness by displaying runtime values inline with the code, eliminating workflow interruptions caused by existing hover-based interactions. The projection boxes are evaluated with a user study, with the aim to explore what impact the feature has on a programmer’s development process. Results indicate that projection boxes enhance usability and effectiveness while maintaining minimal performance overhead.
(paper)
(code)
Extending JastAdd Bridge: Bringing more features from LSP into JastAdd
Julia Karlsson and Philip Sadrian
Abstract:
Many features exist in modern IDEs to improve the programming workflow of developers, such as code completion, go to definition, refactoring and symbol outlines of a text file. These features are often provided by language servers. However, implementing a language server is tedious, even though the Language Server Protocol exists to standardize the process. In this paper, we present continued work on the JastAdd Bridge (JAB) extension for Visual Studio Code (VS Code), thus expanding the translation layer between JastAdd defined languages and the Language Server Protocol.
Our work resulted in the addition of symbol outline and code completion functionality. We found that JAB now seems to support most integral LSP functionality, while still being simple to implement through both a case study of integration with ExtendJ and a small user study.
(paper)
(code)
Metavis: Visual debugger for MetaDL
Emil Blennow
Abstract:
This paper introduces a tool for visualizing static bug reports generated by MetaDL.
By utilizing a terminal UI the analysis results from MetaDL become easier to understand, debug and make use of.
Taking inspiration from other terminal based UI the tool aims to be easy to learn and quickly usable.
(paper)
(code)
JVM Bytecode Backend for SimpliC
Lukas Tröjer and Suleyman Zahi
Abstract:
In this paper we introduce a Java Virtual Machine (JVM) backend for SimpliC, a small language similar to C.
A program written in SimpliC can thus be compiled to Java bytecode and run on the JVM.
This allows for the use of many features that are often desirable, like platform independence and runtime optimizations.
We then evaluate the performance of our generated bytecode using various benchmarks.
Our results show that, compared to the bytecode generated by javac, our generated bytecode has virtually identical steady-state performance and only slightly worse start-up performance.
Furthermore, the performance only becomes better with newer versions of Java.
Our generated bytecode has not been able to be on par with optimized x86 assembly compiled from C, but can easily beat unoptimized x86 assembly on longer-running tasks.
(paper)
Finding and Resolving Common Code Style Errors in Java
Mark Lundager and Andreas Bergqvist
Abstract:
Verbose code with highly specialized if-statements containing return-statements for the different cases of the conditions is harder to maintain when compared to a single return-statement containing the condition.
It is commonly referred to as a code style error.
In this report we present a tool which can be used as an extension in your IDE, and performs on-demand analysis of your code to discover, and repairs to your style violations.
All while using the same variables, constants and general structure of your original code.
There is no change in functionality of the written code.
It is also able to preserve the comments you may have in your original code.
With this tool we hope to help people who are prone to these style errors to kick that habit.
(paper)
(code)
Robot Comment Fixed Detector
Patrik Fjellstedt and Joakim Svensson
Abstract:
Today there exists a lot of tools to analyze existing code to generate useful feedback for the programmer.
When these tools are used with code review tools, such as Gerrit, this feedback is also known as robot comments.
Generating feedback upon code review is a useful workflow to prevent bugs and improve code quality before accepting changes into a project’s main branch.
A problem that arises with the use of such tools though is the amount of generated comments and their accuracy for them to be useful.
This points to a need for a pre-processing step where some comments could be filtered out before presenting them to the user.
We focused our attention on one such tool, ErrorProne, which is a static analysis tool for Java that helps to identify errors during compilation.
Using this tool we tried to detect whether a robot comment was fixed between its head version and the revised version.
(paper)
Garbage collection: Reference-Sweep
Hannes Brinklert and Christoffer Fjällborg Rinaldo
Abstract:
The stack and the heap are two different parts of the memory which a programming language usually requests memory from.
Both of them are used for reading and writing data, but they are used for different purposes.
The goal of this paper is to describe the work of extending a compiler built at a university course that only supports stack allocation, to support arrays with heap allocation.
A further goal is to implement a garbage collection algorithm Reference-Sweep, which is a combination of mark-and-sweep and reference counting, and evaluate its performance.
It was a successful implementation of heap-allocated arrays with manual memory allocation and the garbage collection algorithm Reference-Sweep.
The evaluation shows that when garbage collection is enabled in the SimpliC compiler it is slower than the same program with manual memory allocation.
SimpliC with garbage collection’s performance was worse than a similar Go program and as expected the same was true when compared against a similar program written in C.
The paper creates a framework for future implementation of other garbage collection algorithms and the implemented Reference-Sweep algorithm can be evaluated against other garbage collection algorithms.
(paper)
JastAdd Bridge: Interfacing reference attribute grammars with editor tooling
Johannes Hardt and Dag Hemberg
Abstract:
Nowadays, programmers expect rich editor support when writing code, such as type hints, code completions,
and warnings. While this is present in mainstream languages and editors, lacking such tooling can be a
pain point when developing your own language.
Our paper proposes an extension for the VS Code editor, JastAdd Bridge, that acts as a translation
layer between languages developed with the JastAdd framework and the language server protocol (LSP).
We find that it facilitates rapid integration with editor tooling while preserving flexibility
in the way language authors choose to interact with the programming environment.
(paper)
(code)
Detecting and Fixing Common Code Style Issues in Java
Alexander Magnusson
Abstract:
Code style is an important aspect of programming.
While two different pieces of code may perform the same task logically
one might be simpler to read and understand than the other.
Code written in an unnecessarily complex way might show that the
author might not have fully understood a certain concept.
In addition to reducing the complexity of the code itself,
adhering to a common code style help multiple developers
collaborating on the same code base understand code written by others quicker.
(paper)
(code)
Evaluation of ARM Assembly Generation for a Graduate Compiler Course Compiler
Per Filip Heden and Fritjof Bengtsson
Abstract:
This paper presents an evaluation of using ARM assembly instead of x86 for code generation in a basic compiler,
written in a introductory compiler course at LTH.
The new ARM assembly generator specifically targets Raspberry Pi hardware.
The evaluation is based on the assembly languages usability for students learning about compilers.
First a code generator for ARM was implemented.
Then the language was extended with functions for interacting with GPIO hardware.
Final conclusions from comparing x86 and ARM programs generated by the compiler was
that they were almost identical.
However, the Raspberry Pi gives students the opportunity to more directly interact
with the hardware which other studies has found to be increasing student engagement and results.
(paper)
(code)
Usability of Alternative Semantic Highlighting Features
Charlie Ringström and Jonathan Frisk
Abstract:
Today most programmers use some kind of active programming support when coding,
such as auto completion and function references. One of these features is semantic highlighting.
For this project, this is implemented with a language server that communicates with the text editor.
This paper explores three different ways to semantically highlight the code.
The first feature highlights Strings compared with the == operator to indicate
that the code might be flawed.
The other features highlights both for loop variables with unique colors, and
also each bracket pair a unique color. By using the ExtendJ Java compiler, the
proposed language server communicates with the text editors using LSP.
The for loop variable highlighting and bracket coloring features were evaluated
by showing code snippets to 12 test subjects, with or without semantic highlighting,
and the time to solve each programming task was measured.
For the two tests, the results showed a 5 % and a 13% reduction in time to solve
each programming task with the semantic highlighting enabled.
However, the standard deviation is too big to draw any conclusions.
Additionally, it remains unknown how the results would change in real life usage.
(paper)
(code)
A Framework For Efficient Code Fixes Using Reference Attributed Grammars
Charlie Mrad
Abstract:
Code fixes tools are essential for any developer and are often a feature of the
more popular IDEs available today.
They provide an efficient way for a programmer to learn potentially better ways
to write their code and fix the potentially erroneous code automatically.
The problem today comes from a lack of efficiency in how quickly the code fixes
can be found and generated and how language analysing extensions for IDEs are
being developed.
This paper proposes a framework that can efficiently find potential errors in
Java code using IntraJ and provide quick-fix options.
To avoid spending a significant amount of time implementing and maintaining LSP
support for the framework Magpie Bridge is used.
This combination provides a solid foundation to quickly provide an expandable
array of code fixes.
The initial evaluation seems to outperform Soot on a similar test case.
There is still plenty of room for improvement on the proposed framework,
but it appears to hold up reasonably well as a starting point.
(paper)
(code)
Extending a ChocoPy compiler to include lists and classes on the heap
Ellen Grane and Samer Alkhodary
Abstract:
ChocoPy is a programming language intended to be used for learning about compilers.
An existing ChocoPy compiler was extended to support heap-dynamic lists and
classes stored on the heap.
This was done in order to examine the suitability of the ChocoPy language to be
used for learning about compilers in an advanced course.
The speed of the extended compiler was compared to the standard Python interpreter
and the results showed the ChocoPy compiler to be much faster.
It was concluded that ChocoPy would work well for teaching more about compilers
due to its many features, however providing stable bases for the students is
probably needed in order to implement them, as underlying bugs can lead to many issues.
(paper)
(code)
A Specialized B-Tree data structures for Datalog Evaluation in Java
Louise Adolfsson and Simon Tenggren
Abstract:
Today there is a high demand for Datalog engines to be able to handle large amounts of data quickly.
By implementing a B-Tree in Java there can be significant improvements to its efficiency.
In this paper we present and evaluate the Java implementation of a specialized B-Tree data structure.
Our B-Tree handles parallel insertions and dense data. It uses a hint system for
faster traversals in the B-Tree and has a optimistic read-write lock that allows
for it to handle several threads at once efficiently. The B-Tree outperforms the
TreeSet greatly and is just slightly better than the Concurrent SkipList Set in some cases.
The B-Tree shows potential as a replacement for Java’s data structures from the results of the benchmarks.
(paper)
(code)
Flow Based Bug Detection
Oskar Kari
Abstract:
Program analysis is an important tool in modern software developement.
In this paper a program analysis tool that solves the redundant assignment problem
will be described. This tool will be tested on a real program as well as on
smaller test programs. The performance will be analysed and some suggestions for
further work will be done.
(paper)
(code)
ChocoPy compiler
Tobias Karlsson
Abstract:
The purpose of this essay is to investigate the possibility of using ChocoPy
as the programming language when educating students on how to construct a
compiler as well as comparing the performance of the ChocoPy compiler with a python compiler.
The compiler for ChocoPy is implemented to generate assembly code, targeting X86.
ChocoPy could be advantageous to use when teaching compilers since it is a
simplified subset of Python. When comparisons were made between the ChocoPy
compiler and python interpreter for a certain type of program, the result was
that the ChocoPy compiler was between 10 and 20 times faster, depending on the
size of the program. A ChocoPy compiler can be created in a compiler course
since the resources and knowledge provided by the course is enough to handle all
the problems that may arise.
(paper)
(code)
Breaking Student Parsers with Generated Test Cases
Filip Johansson
Abstract:
In this paper we try to increase the coverage of a handwritten test suite used to test student parser grammars.
To do this we construct a tool, called NeoTestGen, that generates test cases for parsers based on an input grammar.
This is done by extending the parser generator NeoBeaver.
NeoTestGen can generate both positive and negative test cases, that is test cases that the parsers should pass or fail respectively.
The resulting tool can quickly generate a large test suite with large coverage; however, there some tests in the handwritten suite that could not be generated.
Furthermore, no tests in the generated suite were found to increase the coverage of the handwritten one.
(paper)
(code)
SimpliC in the browser
Wilmer Nilsson and Andreas Trattner
Abstract:
More and more software has been making its way into the browser. Usually this involves rewriting the software in web specific languages,
or creating complex APIs with which the front-end can communicate with a high-performance back-end.
Now, however, with the help of WebAssembly, a general-purpose virtual instruction set created in the likeness of low-level assembly languages,
it is possible to weave performant code into JavaScript, a typical front-end language, which is run through the V8 engine, potentially increasing performance.
At the moment, WebAssembly is able to be generated from C, C++, Rust, Go and all LLVM compatible languages.
In this paper, the potential advantages and disadvantages to this approach of web programming will be discussed.
The creation of a WebAssembly-compiler will also be explored, using a simpli ed C-like source language.
With our compiler ready we then perform several benchmarks, comparing the speed of emcc (C to WebAssembly) compiled WebAssembly code to,
amongst others, our own compiler’s and Javascript’s.
As expected our compiler was the slowest contester, finishing just after Javascript.
The emcc-generated WebAssembly code however, is faster than Javascript albeit slower than languages
such as Rust and Java, when run natively.
With JIT-compilation turned off in Javascript even our compiler produces code that is
magnitudes faster – a fact that could be used to emphasise the need of JIT-functionality in WebAssembly.
(paper)
(code)
An MPS implementation for SimpliC
Raphael Castanier
Abstract:
The goal of this study was to evaluate JetBrains language editor provided as an Open Source project called MPS
(Meta-Programming System).
One way to evaluate MPS performances for designing simple language compiler was to
implement the SimpliC language in MPS through its projectional editor.
We will present in this paper what a projectional editor is and its opportunities for language design.
Then we will introduce basic concepts of language design in MPS through our SimpliC implementation,
and discuss the lessons we learned from this.
We also discuss an evaluation of this process and present related academic work.
(paper)
(code)
DeepCode phase 1: Compilers approach
Miquel Puig i Mena
Abstract:
Yet being immersed in the globalisation era, we can still perceive isolation and rivalry between software developing teams that share ambitions.
Nonetheless, DeepCode proposes a cooperation between parties in order to achieve greater results.
DeepCode is a tool that, by processing a data-set formed by source codes performing a generic task A,
learns how to implement task A and outperform every individual from studied data-set.
Unfortunately, no existing tool is capable of homogenizing a source code data-set in a manner
that can be post processed by AI tools.
DeepCode phase 1 targets to fill this gap in the field by offering a standardised data structure
representing a generic source code.
Furthermore, this paper presents a practical application that generates aforementioned representation
given a well-formed source code file.
(paper)
(code)
Datalog Implementation in JastAdd
Hampus Balldin
Abstract:
This paper presents the implementation of a new programming language belonging to the Datalog family. A short background on Datalog, its theoretical foundations, and its applicability for practical problems is introduced. A number of extensions to the core Datalog language are presented, the most novel of which is to allow predicates to be used as terms in atoms. As will be shown, this enables a compact description of various meta properties such as encoding what tables to output, or to give static types to predicates.
(paper)
(code)
Extending Java with String Interpolation Using ExtendJ
Wilhelm Lundström and Oskar Damkjaer
Abstract:
String interpolation is a syntactic feature commonly found scripting languages such as Python and Perl. It can be used to simplify the code for printing and manipulating strings, making the code easier to both read and to write. There is currently no support for this feature in Java (the current version being Java 11).
In this project, we bring string interpolation to Java by extending the extendable Java compiler ExtendJ[4]. The implementation is functional and backwards compatible, so existing code will not be affected by this extension (save for rare, specific cases).
Our implementation is rather light weight, yet effective. The full feature of string interpolation is implemented in a few short files, yet has a significant potential effect on the way Java code is written.
We evaluate the impact of this feature by analysing how effectively it could be used in larger Java projects. Looking at open source projects, we examined how much string interpolation could be used in the projects.
(paper)
(code)
Language Server Protocol for ExtendJ
Fredrik Siemund and Daniel Tovesson
Abstract:
Microsoft’s Language Server Protocol (LSP) has been implemented with ExtendJ in two widely popular Integrated Development Environments (IDE), Eclipse and Sublime Text. LSP is a way of supplying high level support — such as code completion, hover tooltips, jump-to-definition and find-references — for a programming language in a wide variety of editors. ExtendJ is an extensible compiler for Java, specified using reference attribute grammars. Because of the time limit of the project, only error checking was implemented. As the user writes Java code, the IDEs will highlight erroneous code and thereby simplify the process of finding errors. On the client side, this was done by configuring two extensions, one for each IDE. On the server side, a language server was created that compiles the file with ExtendJ every time it is changed by the user to search for compilation errors. To make LSP work flawlessly with ExtendJ, an extension to ExtendJ was created.
(paper)
(code)
Design By Contract Implementation For ExtendJ
Martin Lindström and Jakob Hök
Abstract:
The paper demonstrates how Design By Contract (DBC) was integrated into the aspect-oriented Java compiler ExtendJ by using annotations. The scope of the implementation was limited to only include preconditions, i.e., only method-input validation. Adding DBC into Java, is a handy way of validating execution and also to improve readability. Therefore, DBC is a desirable feature to implement. ExtendJ makes use of aspect-oriented programming to compile Java code. Extending the compiler was therefore convenient and allowed the implementation to conform to the open-closed principle. The preconditions’ byte code was inserted before the method’s or constructor’s byte code. Hence, the precondition validation is run before the method’s code. An exception is thrown if any precondition is not met. In the end, the extension supports preconditions NotNull, MinValue, MaxValue, Not and arbitrary preconditions with the annotation Requires.
(paper)
(code)
Declarative Program Analysis and Interpretation for AttoL
Anton Göransson
Abstract:
I have implemented an interpreter for a small object-oriented language called AttoL. I then experimented with different kinds of program analysis. This was all done using JastAdd, which makes it possible to write declarative code. The idea is that the interpreter will be used for experimenting with declarative program analysis with attribute grammar since it has not been done that much before. I then evaluated my implementation by comparing program execution speed and source lines of code to the original AttoL implementation. The results were positive and I definitely think that JastAdd is a viable option for implementing program analysis. Because of JastAdd’s modularity is easy to add new functionality without having to change old one, creating a maintainable and decoupled system.
(paper)
(code)
Extending Java with the Exponentiation and Safe Navigation Operators
Emma Asklund and Victor Winberg
Abstract:
This report describes the implementation of the exponentiation and safe navigation operators as extensions to the Java compiler ExtendJ. Our implementations of these operators in ExtendJ is functional and can be used to compile existing Java programs. Bytecode generation is also supported. The implementation of these operators is small, thanks to mapping to pre-existing language constructs.
We have evaluated the safe navigation operator by looking into benefits of using the save navigation operator in three Java and three Groovy open source projects. The conclusion after looking into these six projects is that the safe navigation operator is not as useful as we thought it would be.
(paper)
(code)
Reference Attribute Grammars in Python
Christoffer Olsson and Liang Ce
Abstract:
This is a short report on a Python library that implements so called reference attribute grammars. Reference attribute grammars are in short a way to give attributes to already existing tree data structures. Attributes are computed properties of nodes in a tree, defined by equations. The ability to attribute trees is something that is very useful in for example compiler construction. There are already several implementation of reference attribute grammars in languages such as Java and Scala. However there are none in more dynamic languages such as Python. Therefore this report presents a small library written in Python that enables an end user to attribute any tree like data structure in the very same language.
(paper)
(code)
Reducing error prone code by analyzing immutability
Oskar Berg and Ruolangxing Zhang
Abstract:
Immutability is long known for its advantages of automatically being thread-safe and it works without synchronization issues. As we were very interested in this area and intend to reduce errors for programmers. We built a tool based on java compiler Extendj, so when compiling the program, the tool produces warnings for potentially wrong mutable fields, which includes every mutable parameter type as well as every static field that are mutable. To achieve this we implemented functions such as isMutable(), exposeReference() and so on. These are two typical cases that mutability could cause errors. It is a useful tool which can be further developed.
(paper)
(code)
Language Server Protocol for ExtendJ
Joakim Ericson
Abstract:
Integrated Development Environments (IDEs) are popular tools and while they have their benefits, such as diagnostic messages in the editor, code completion, or debugging. However a drawback of most modern IDEs is the fact that they only work with a handful of languages, that they are developed for. The Language Server Protocol (LSP) was developed to extract some of the language related functionality of an IDE 1and make it available for any editing software that would implement a client for the LSP. Currently there are two major language servers for Java. One using the official Javac compiler, and the other using Eclipse’s jdt compiler. While both of these solutions work fine for working with the standard features of Java, if there were new features of Java that one wanted to test and still have full support by a language server, that would not work currently. Thus we propose to create one using the compiler ExtendJ2, that is developed at Lund University. We decided that we wanted to implement a language server using ExtendJ due to the fact that it is designed to be easy to extend Java with new features. Since this proposal combines ExtendJ with the LSP any existing editor, such as vim or sublime, both of which has a working client would be usable. And can provide helpful features such as code completion and other such features that an IDE would traditionally provide. While adding the extensibility of ExtendJ to the mix.
(paper)
(code)
Implementation of PQL in Java 8 using ExtendJ
David Åkerman and Yu Zhang
Abstract:
Effective use of parallelism can improve performance, but it is at the same time hard to get right. A solution to this problem is to use language specially designed to make parallelism easy, PQL is one such language. PQL is a query language embedded in Java which tries to make parallelism easier for the programmer by letting the underlying implementation take care how the computation is done. PQL has only been implemented in Java 6 and Java 9 has already been released. The PQL language can be implemented in the extensible Java compiler ExtendJ which is highly modular and more easily updated when a new version of Java is released. We have implemented a subset of PQL in ExtendJ and evaluated its performance. We found that our implementation was a bit slower than a parallel Java8 Streams in some benchmark, but has the same performance in other benchmarks.
(paper)
(code)
Extending Java with new operators using ExtendJ
Wawrzyn Chonewicz and Filip Stenström
Abstract:
We have used the extensible Java compiler ExtendJ to add two new operators to the java language: print-assign and a simplified spread operator. The print-assign operator extends the assignment operator by also printing, and the spread operator creates a new array by applying a method to each element of an array. In this paper we describe the implementation, which consists of both static analysis and bytecode generation, and highlight some interesting problems.
We evaluate the applicability of our operators by scanning a few open-source projects for use cases. We also evaluate the performance of our extension by compiling a few open- source projects, and we conclude that there is no noticeable difference in compilation time with or without our extension.
(paper)(code)
Extending the ExtendJ Java compiler with Java 9 support
Sebastian Hjelm and Markus Olsson
Abstract:
This report covers our extension of the ExtendJ compiler to cover parts of the Java 9 specification. We will discuss the changes we have implemented and how they work in detail. We have also made an evaluation which verifies that our extension has little performance impact on the existing compiler.
(paper)(code)
Dependency Injection in Java
Niklas Jönsson and Kim Fransson
Abstract:
In this paper we discuss the problems of slow execution times as a result of sub-optimal choices for the underlying data structures. We present our dependency injection extension for Java that collects information about library collection type uses and makes an intelligent choice on what data structure to use.
Our solution lets the programmer decide if he wants help from the compiler to make the choice by specifying an interface type on the right hand side of an assignment when declaring a variable.
Our solution scratches the surface of dependency injection and achieves performance gains. However there is still a lot to be discovered and these gains could be greater with more work.
(paper)(code)
A Coroutine Extension to Java
Adam Ohlsson and Erik Leffler
Abstract:
This paper present an extension to the ExtendJ Java compiler that enables the use of asymmetric, first-class, stackless coroutines. The extension perform syntactic sugaring and generate standard Java code, acting as a translator. The extension currently provide support for a fairly large subset of Java but does not provide error checking or error messages.
(paper)(code)
Implementation of graphical editor using Sirius
David Phung
Abstract:
One of the first steps in the process of model-driven development is to construct an editor that would allow for creation and modification of models. For domain specific languages, there might not be an existing product on the market that have support for the language. Moreover, the cost of building one such editor can be too expensive if done from the ground up. A number of tools and frameworks have therefore been developed to help alleviate this problem. We present our study of one such frameworks, Sirius. Sirius is an Eclipse project aims at enabling rapid development of graphical editor without high level of required knowledge. By implementing an editor ourselves using the framework, we have highlighted a number of its strengths and the factors that should be considered before a developer unfamiliar with Eclipse modeling projects can start using Sirius.
(paper)(code)
Java Code Cleanup using ExtendJ
Hannes Jönsson and Felix Olsson
Abstract:
In order to reduce code size, ensure proper functionality of overridden methods as well as improve clarity of which imports are actually used, a code cleanup tool can be used. This report describes the implementation of such a tool based on the ExtendJ Java compiler. The tool is compared to other tools with similar functionality and its functions are evaluated. The conclusions we draw is that the tool does not produce correct results under all circumstances, a result of the difficulty to ensure coverage of all possible Java functionality.
(paper)
(code)
Extending Java with new operators
Hans Bjerndell and Linus Lexfors
Abstract:
We have explored the possibilities of extending the syntax of the Java programming language with a new operator, known as the spread operator, using the extensible Java compiler ExtendJ. The spread operator is a binary operator that accesses a field or calls a method on each object in a collection, a feature we believe to be highly useful. Our extension to ExtendJ consists of new parsing rules, static analysis and a new node type in the abstract syntax tree (AST). Bytecode generation is left as future work, the extension we have developed serves as a basis for further development. In this report we describe the process of developing the extension and provide examples of the spread operator in use. Finally we evaluate the extended compiler, measuring compile-time and comparing the results with the ExtendJ base compiler.
(paper)(code)
Extending Simplic with an LLVM backend
Kasper Bratz and Erik Hedblom
Abstract:
This paper explores the concept of extending an already existing compiler with a back-end for generating LLVM-intermediate code in place of x86-assembler code. A LLVM back-end will be written for an existing compiler for the the language SimpliC, a bare bones implementation of C, to examine what benefits can be made using LLVM. The SimpliC language will also be extended with some new functionality to compare complexity of implementation for x86-assembly and LLVM.
(paper)
LLVM code generation and implementation of nested functions for the SimpliC language
Oscar Legetth and Gustav Svensson
Abstract:
This report will cover our work on the extension of the SimpliC language(a simple C-like language) and its compiler. We will describe SimpliC’s features and the extensions we have made to it. The compiler has been extended with support for LLVM code generation. LLVM code lets us use the different optimization tools that LLVM has. We will then compare the optimized LLVM code with the assembly code that our compiler generated before we started this project in terms of execution time. We will also describe how we implemented the extensions and the LLVM code generation, and the different problems that came along with it.
(paper)
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)
LR conflict demonstrator
Daniel Eliasson and Christian Olsson
Abstract:
It can be difficult to resolve conflicts in a LR grammar. This tool hopes to help alleviate this problem. The tool finds a string of symbols leading up to a conflict in order to give an example of something that is ambigous to the parser. We do this by building a graph from the output dumped by the CUP parser generator and doing a search from the start node of the graph to the conflict state, generating a string of symbols.
(paper) (code)
Object-oriented metrics for Java programs
Olle Tervalampi-Olsson and Marcus Lacerda
Abstract:
A key aspect of software metrics, are dependencies. That is, how different classes and packages make use of each other to construct a program. Object-oriented metrics allow these dependencies to be analyzed and give an overview of how stable and healthy the program is for some aspects. We introduce a new tool that is an extension of the JastAddJ compiler and calculates these metrics on java source code, similar in functionality to JDepend and some functions that exist in CodePro Analytix.
(paper) (code)
Package metrics on Java projects
Joel Lindholm and Johan Thorsberg
Abstract:
A tool for calculating metric suits over both java source code and its belonging libraries has been implemented. As of this report the tool is able to use the Chidamber & Kemerer object-oriented metrics suite and the Martin Metric suite. A configuration file exist and is used to change the behavior of the calculations and its output. There also is an ignore file that can be used to ignore specific packages, these will not be included in the calculations.
The tool has been implemented as extension to the JastAddJ compiler, and is therefore easily extended or modified.
Evaluation proved that the tool have an acceptable evaluation time.
(paper) (code)
JastAdd library for name analysis
Daniel Forsman and Jakub Gorski
Abstract:
During the process of constructing a compiler there are several steps that are crucial to the analysis of code. This paper will stage one of these steps, namely the development of a name analysis library. This will allow programmers to easily modify the name analysis, which will enable more versatile prototyping of compilers at the name analysis stage. By exploring the possibility for a name analysis library for JastAdd, an attempt to implement a generic name analysis library will be made, such that it supports several languages.
(paper) (code)
A SimpliC compiler in Scala and Kiama
Johan Andersson
Abstract:
JastAdd and Kiama are both tools that support working with attribute grammars in compiler construction. JastAdd is a tool that generates Java code, while Kiama is a Scala library.
In this project, a compiler was created for a simple C-like language, using Kiama and Scala. A compiler for this language has previously been implemented, but instead using JastAdd.
These two compilers were then evaluated in terms of code size and performance, to see how well they performed. The goal of this project was to compare Kiama with the more widespread tool JastAdd.
(paper)
Compiler in Scala and Kiama in comparison with JastAdd
Andree Ekroth and Felix Mulder
Abstract:
This paper examines the main differences in usability and performance between Kiama, a Scala library for language processing, and the combination of tools used in course Compilers EDAN65 offered at Lund Institute of Technology. Specifically the focus of the paper is how well Kiama can perform with the aid of Scala compared to JastAdd which generates Java code. The Scala language is considered a more advanced, and by some an experimental language when compared to Java. As such there will also be a focus on how feasible the usage of Kiama is versus using JastAdd or alternatively a compiler implemented by hand for production.
(paper)