sky 1c01e1de78 fork & optimize: 从github上获取官方源码,并进行了一些优化(不过不保证完全没问题) пре 3 година
..
src 1c01e1de78 fork & optimize: 从github上获取官方源码,并进行了一些优化(不过不保证完全没问题) пре 3 година
README.md bb31a37434 Merge branch 'master' into refactoring/languages пре 4 година
pom.xml 9422dec832 Move to new structure пре 4 година

README.md

JPlag Go language frontend

The JPlag Go frontend allows the use of JPlag with submissions in Go.
It is based on the Golang ANTLR4 grammar, 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 recent1 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.
Blocks are distinguished by their context, i.e. there are separate TokenTypes 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 and in the wiki.


Footnotes

1 The grammar files are taken from grammar-v4, with the most recent modifiactions in commit 51ecccf from April 2022.