VMF-Text is a novel framework for grammar-based language modeling on the Java Platform (it works with Java 8, 9, 10 and 11): give it a labeled ANTLR4 grammar and it will generate a rich and clean API (based on VMF) for (un)parsing and transforming custom textual languages. The complete API is derived from just a single ANTLR4 grammar file!
Checkout the tutorial projects: https://github.com/miho/VMF-Text-Tutorials
VMF-Text comes with excellent Gradle support. Just add the plugin like so (click here to get the latest version):
plugins {
id "eu.mihosoft.vmftext" version "0.1.2.7" // use latest version
}
(optionally) configure VMF-Text:
vmfText {
vmfVersion = '0.1.1' // (runtime version)
antlrVersion = '4.7.1' // (runtime version)
}
Now just add the labeled ANTLR4 grammar file to the VMF-Text source folder, e.g.:
src/main/vmf-text/my/pkg/ArrayLang.g4
Sample grammar for parsing strings of the form (1,2,3)
:
grammar ArrayLang;
array: '(' values+=INT (',' values+=INT)* ')' EOF;
INT: SIGN? DIGIT+
;
fragment SIGN :'-' ;
fragment DIGIT : [0-9];
WS
: [ \t\r\n]+ -> channel(HIDDEN)
;
/*<!vmf-text!>
TypeMap() {
(INT -> java.lang.Integer) = 'java.lang.Integer.parseInt(entry.getText())'
}
*/
Finally, call the vmfTextGenCode
task to generate the implementation.
Open the VMF-Text/core
Gradle project in your favourite IDE (tested with NetBeans 8.2 and IntelliJ 2018) and build it
by calling the publishToMavenLocal
task.
Navigate to the Gradle project (i.e., path/to/VMF-Text/core
) and enter the following command
bash gradlew publishToMavenLocal
gradlew publishToMavenLocal
Open the VMF-Text/gradle-plugin
Gradle project in your favourite IDE (tested with NetBeans 8.2 and IntelliJ 2018) and build it
by calling the publishToMavenLocal
task.
Navigate to the Gradle project (i.e., path/to/VMF-Text/gradle-plugin
) and enter the following command
bash gradlew publishToMavenLocal
gradlew publishToMavenLocal
To execute the test suite, navigate to the test project (i.e., path/to/VMF-Text/test-suite
) and enter the following command
bash gradlew test
gradlew test
This will use the latest snapshot vmf-text and gradle-plugin to execute the tests defined in the test-suite project.
An HTML version of the test report is located in the build folder test-suite/build/reports/tests/test/index.html
.
Test reports of the travis builds are available as well: [Test reports]