-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Kotlin frontend #475
Add Kotlin frontend #475
Changes from all commits
a4fa7eb
8547791
24023ce
e417e11
31d1c19
4c93216
d0e2331
d7a3a55
652ac52
0b1ed7a
2753aa3
d7d543b
4ec51ac
78bf634
0aa68f9
3ca4aca
24f050b
1644cd1
e397677
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ Usage: JPlag [ options ] [ <root-dir> ... ] [ -new <new-dir> ... ] [ -old <old-d | |
|
||
named arguments: | ||
-h, --help show this help message and exit | ||
-l {java,python3,cpp,csharp,char,text,scheme} Select the language to parse the submissions (default: java) | ||
-l {java,python3,cpp,csharp,rlang,kotlin,char,text,scheme} Select the language to parse the submissions (default: java) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move added "rlang" to different PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is what I thought. Luckily, this is only text and no functional part that was missed. |
||
-bc BC Path of the directory containing the base code (common framework used in all submissions) | ||
-v {quiet,long} Verbosity of the logging (default: quiet) | ||
-d Debug parser. Non-parsable files will be stored (default: false) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# JPlag Kotlin language frontend | ||
|
||
The JPlag Kotlin frontend allows the use of JPlag with submissions in Kotlin. <br> | ||
It is based on the [Kotlin ANTLR4 grammar](https://github.com/antlr/grammars-v4/tree/master/kotlin/kotlin), licensed under the Apache 2.0. | ||
|
||
### Kotlin specification compatibility | ||
|
||
The underlying grammar definition does not specify which version of Kotlin it is built on, but the presence of the `inline` keyword and the lack of support for trailing commas in argument lists indicate that it complies with Kotlin 1.3, released in late 2018. | ||
|
||
The grammar in this repo contains a fix and some modifications to allow for easier token generation, see the comment in the [KotlinParser](src/main/antlr4/de/jplag/kotlin/grammar/KotlinParser.g4). | ||
|
||
If there are any major updates or fixes to the grammar<a href="#footnote-1"><sup>1</sup></a>, they should surely be applied to this module as well. | ||
|
||
|
||
### Token Extraction | ||
|
||
The choice of tokens is intended to be similar to the Java or C# frontends. It includes a range of nesting structures (class, method, control flow expressions) as well as variable declaration, object creation, assignment, and control flow altering keywords. | ||
|
||
More syntactic elements of Kotlin may turn out to be helpful to include in the future. | ||
|
||
### Usage | ||
|
||
To use the Kotlin frontend, add the `-l kotlin` flag in the CLI, or use a `JPlagOption` object set to `LanguageOption.KOTLIN` in the Java API as described in the usage information in the [readme of the main project](https://github.com/jplag/JPlag#usage) and [in the wiki](https://github.com/jplag/JPlag/wiki/1.-How-to-Use-JPlag). | ||
|
||
<br> | ||
|
||
#### Footnotes | ||
<section id="footnote-1"><sup>1 </sup>The grammar files are taken from grammar-v4, with the most recent modification in <a href="https://github.com/antlr/grammars-v4/tree/9644ff90b769cecf2ee0089c88993042e401a75e/kotlin/kotlin">commit 9644ff9</a> from February 2021.</section> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>de.jplag</groupId> | ||
<artifactId>aggregator</artifactId> | ||
<version>${revision}</version> | ||
</parent> | ||
<artifactId>kotlin</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.antlr</groupId> | ||
<artifactId>antlr4-runtime</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>de.jplag</groupId> | ||
<artifactId>frontend-utils</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>de.jplag</groupId> | ||
<artifactId>frontend-testutils</artifactId> | ||
<version>${revision}</version> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.antlr</groupId> | ||
<artifactId>antlr4-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>antlr4</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is also part of https://github.com/jplag/JPlag/pull/500/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R51