jdmonin / JSettlers2

Java Settlers project home, downloads, and GPLv3 source code. To download the latest version as a JAR, see https://github.com/jdmonin/JSettlers2/releases/latest .
http://nand.net/jsettlers/
GNU General Public License v3.0
157 stars 63 forks source link

Add formal syntax #39

Closed generateui closed 3 years ago

generateui commented 6 years ago

An ANTLR syntax is written in JSettlers.g4 grammar file. In the test/resources folder example script can be seen which actually succeed in parsing. For info on why using the syntax, please read the .g4 file. In the tests folder you can see some idea prototypes what we can do with the syntax. I have created one (faulty I now see) change in SOCResourceSet where you can instantiate a SOCResourceSet using a syntax element (ResourceSetContext).

You should be able to do a build using gradle. Code is then generated from the ANTLR grammar file (lexer & parser) into build/generated-src/main/antlr. You may need to explicitly include this code into your project as IDE's may be oblivious to it. After that, it should compile and tests should pass. Most tests do not test stuff, but show you output in the console.

This PR is not intended to be merged but intent is to show what's possible using a syntax.

jdmonin commented 3 years ago

Thanks again for the interesting idea.