-
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 Golang frontend #500
Merged
Merged
Add Golang frontend #500
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
419e9b0
Add Go frontend
robinmaisch b9b3f0c
Reformat GoTokenConstants
robinmaisch 9413618
Rename package and artifactId 'go' to 'golang'
robinmaisch 52176ac
Merge branch 'master-remote' into golang
robinmaisch 3fa91a4
Rename 'go' to 'golang', add 'golang' to top level README
robinmaisch 10fad30
Add many more tokens, add tests and README
robinmaisch a913633
Add interface tokens, clean up test
robinmaisch 7a4babd
Remove magic numbers
robinmaisch d75c16b
Reformat code
robinmaisch 87909b8
Add GoTokenUtils
robinmaisch 382d349
Remove code smells detected by sonarcloud
robinmaisch 4ff0ddf
Add link to README
robinmaisch 1bd2b11
Unify equivalent GolangTokenConstants
robinmaisch ada7208
Make Golang frontends more consistent to others -- continued
robinmaisch d43ce72
Merge branch 'master' into golang
robinmaisch 2d77c5c
Reformat code
robinmaisch 066acd0
Merge branch 'master-remote' into golang
robinmaisch c73f4d2
Implement feedback from revision; remove duplicate dependency
robinmaisch 6d8eb4f
Implement feedback from SonarCloud
robinmaisch f4379ac
Reformat code
robinmaisch bb77c0f
Merge branch 'master-remote' into golang
robinmaisch 71aedef
Adapt frontend to interface changes
robinmaisch 3936f20
Add documentation, move GoTokenTestUtils
robinmaisch 8c2d774
Remove redundant method implementations
robinmaisch 8322793
Reformat code
robinmaisch 743a06f
Remove Language::numberOfTokens
robinmaisch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# JPlag Go language frontend | ||
|
||
The JPlag Go frontend allows the use of JPlag with submissions in Go. <br> | ||
It is based on the [Golang ANTLR4 grammar](https://github.com/antlr/grammars-v4/tree/master/golang), licensed under BSD-3. | ||
|
||
### Go specification compatibility | ||
|
||
The underlying grammar definition does not specify which version of Go it is built on. This is what we know: | ||
- Number literal prefixes, a feature of go1.13, are included. | ||
- Generics, a feature of go1.18, are _not_ included. | ||
- Between go1.13 and go1.18, there were no changes to the syntax. So, the grammar should be fully compatible with go1.17, released in mid-2021. | ||
|
||
If the grammar is updated to a more recent<a href="#footnote-1"><sup>1</sup></a> syntax definition, this module should surely be updated as well. | ||
|
||
### Token Extraction | ||
|
||
The choice of tokens is intended to be similar to the Java or C# frontends. Specifically, among others, it includes a range of nesting structures (class and method declarations, control flow expressions) as well as variable declaration, object creation, assignment, and control flow altering keywords. <br> | ||
Blocks are distinguished by their context, i.e. there are separate `TokenConstants` for `if` blocks, `for` blocks, class bodies, method bodies, array constructors, and the like. | ||
|
||
More syntactic elements of Go may turn out to be helpful to include in the future, especially those that are newly introduced. | ||
|
||
### Usage | ||
|
||
To use the Go frontend, add the `-l golang` flag in the CLI, or use a `JPlagOption` object set to `LanguageOption.GO_LANG` 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 modifiactions in <a href="https://github.com/antlr/grammars-v4/tree/51ecccf87b75e96177287367b96cfa99e9f304b8/golang">commit 51ecccf</a> from April 2022.</section> | ||
robinmaisch marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>golang</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>de.jplag</groupId> | ||
<artifactId>frontend-utils</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.antlr</groupId> | ||
<artifactId>antlr4-runtime</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> | ||
robinmaisch marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add dependency to golang here
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.
But that's something we can also do later