Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miho/vmf-text
Powerful Grammar-based Language Modeling Framework
https://github.com/miho/vmf-text
abstract-syntax-tree antlr antlr4 code-generation java model-driven parser unparsing
Last synced: about 2 months ago
JSON representation
Powerful Grammar-based Language Modeling Framework
- Host: GitHub
- URL: https://github.com/miho/vmf-text
- Owner: miho
- License: apache-2.0
- Created: 2018-07-11T18:36:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-12T05:05:38.000Z (7 months ago)
- Last Synced: 2024-06-12T11:04:21.756Z (7 months ago)
- Topics: abstract-syntax-tree, antlr, antlr4, code-generation, java, model-driven, parser, unparsing
- Language: Java
- Homepage:
- Size: 1.09 MB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# VMF-Text [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=VMF-Text:%20The%20new%20framework%20for%20grammar-based%20language%20modeling!&url=https://github.com/miho/VMF-Text&via=mihosoft&hashtags=vmftext,vmf,antlr4,java,mdd,developers)
[![Build Status](https://travis-ci.org/miho/VMF-Text.svg?branch=master)](https://travis-ci.org/miho/VMF-Text)
[![Build status](https://ci.appveyor.com/api/projects/status/vh9eu5fmhhgqo21b/branch/master?svg=true)](https://ci.appveyor.com/project/miho/vmf-text/branch/master)
[![Join the chat at https://gitter.im/VMF_/Lobby](https://badges.gitter.im/VMF_/Lobby.svg)](https://gitter.im/VMF_/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)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](https://github.com/antlr/antlr4) grammar and it will generate a rich and clean API (based on [VMF](https://github.com/miho/VMF)) for (un)parsing and transforming custom textual languages. **The complete API is derived from just a single ANTLR4 grammar file!**
## Using VMF-Text
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](https://plugins.gradle.org/plugin/eu.mihosoft.vmftext) to get the latest version):
```gradle
plugins {
id "eu.mihosoft.vmftext" version "0.1.2.7" // use latest version
}
```
(optionally) configure VMF-Text:```gradle
vmfText {
vmfVersion = '0.1.1' // (runtime version)
antlrVersion = '4.7.1' // (runtime version)
}
```Now just add the labeled [ANTLR4](https://github.com/antlr/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)`:
```antlr
grammar ArrayLang;array: '(' values+=INT (',' values+=INT)* ')' EOF;
INT: SIGN? DIGIT+
;fragment SIGN :'-' ;
fragment DIGIT : [0-9];WS
: [ \t\r\n]+ -> channel(HIDDEN)
;/*
TypeMap() {
(INT -> java.lang.Integer) = 'java.lang.Integer.parseInt(entry.getText())'
}
*/
```Finally, call the `vmfTextGenCode` task to generate the implementation.
## Building VMF-Text (Core)
### Requirements
- Java >= 1.8
- Internet connection (dependencies are downloaded automatically)
- IDE: [Gradle](http://www.gradle.org/) Plugin (not necessary for command line usage)### IDE
Open the `VMF-Text/core` [Gradle](http://www.gradle.org/) project in your favourite IDE (tested with NetBeans 8.2 and IntelliJ 2018) and build it
by calling the `publishToMavenLocal` task.### Command Line
Navigate to the [Gradle](http://www.gradle.org/) project (i.e., `path/to/VMF-Text/core`) and enter the following command
#### Bash (Linux/macOS/Cygwin/other Unix shell)
bash gradlew publishToMavenLocal
#### Windows (CMD)gradlew publishToMavenLocal
## Building VMF-Text (Gradle Plugin)
### Requirements
- Java >= 1.8
- Internet connection (dependencies are downloaded automatically)
- IDE: [Gradle](http://www.gradle.org/) Plugin (not necessary for command line usage)### IDE
Open the `VMF-Text/gradle-plugin` [Gradle](http://www.gradle.org/) project in your favourite IDE (tested with NetBeans 8.2 and IntelliJ 2018) and build it
by calling the `publishToMavenLocal` task.### Command Line
Navigate to the [Gradle](http://www.gradle.org/) project (i.e., `path/to/VMF-Text/gradle-plugin`) and enter the following command
#### Bash (Linux/macOS/Cygwin/other Unix shell)
bash gradlew publishToMavenLocal
#### Windows (CMD)gradlew publishToMavenLocal
## Testing VMF-Text (Core & Plugin)
To execute the test suite, navigate to the test project (i.e., `path/to/VMF-Text/test-suite`) and enter the following command
#### Bash (Linux/macOS/Cygwin/other Unix shell)
bash gradlew test
#### Windows (CMD)gradlew test
This will use the latest snapshot vmf-text and gradle-plugin to execute the tests defined in the test-suite project.
### Viewing the Report
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]](https://vmf-text-tests.mihosoft.eu/)