Browse Source

Add link to README, small simplification to token transformation

Robin Maisch 4 years ago
parent
commit
78bf634b5c

+ 1 - 1
jplag.frontend.kotlin/README.md

@@ -25,4 +25,4 @@ To use the Kotlin frontend, add the `-l kotlin` flag in the CLI, or use a `JPlag
 <br>
 <br>
 
 
 #### Footnotes
 #### Footnotes
-<section id="footnote-1"><sup>1 </sup>Currently, the grammar is taken from grammar-v4, commit 9644ff9 from February 2021.</section>
+<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>

+ 4 - 4
jplag.frontend.kotlin/src/main/java/de/jplag/kotlin/KotlinListener.java

@@ -354,13 +354,13 @@ public class KotlinListener extends KotlinParserBaseListener {
         Token token = node.getSymbol();
         Token token = node.getSymbol();
         String tokenText = token.getText();
         String tokenText = token.getText();
         if (tokenText.contains("@")) {
         if (tokenText.contains("@")) {
-            tokenText = tokenText.substring(0, tokenText.indexOf("@"));
+            tokenText = tokenText.substring(0, tokenText.indexOf("@") - 1);
         }
         }
         Optional<Integer> type = switch (tokenText) {
         Optional<Integer> type = switch (tokenText) {
             case "throw" -> Optional.of(THROW);
             case "throw" -> Optional.of(THROW);
-            case "return", "return@" -> Optional.of(RETURN);
-            case "continue", "continue@" -> Optional.of(CONTINUE);
-            case "break", "break@" -> Optional.of(BREAK);
+            case "return" -> Optional.of(RETURN);
+            case "continue" -> Optional.of(CONTINUE);
+            case "break" -> Optional.of(BREAK);
             default -> Optional.empty();
             default -> Optional.empty();
         };
         };