Commit 69479d66 authored by René Schöne's avatar René Schöne
Browse files

Merge branch 'dev' into 'master'

0.4.0

Closes #27

See merge request !20
parents 2dffc2f1 699ebb7a
Pipeline #12984 passed with stages
in 1 minute and 55 seconds
......@@ -13,4 +13,3 @@ src/test/jastadd/*/*.ast
src/test/jastadd/*/*.jadd
src/test/jastadd/*/*ResolverStubs.jrag
!src/test/jastadd/*/MyRefResolver.jadd
/gradle.properties
stages:
- build
- test
- jar
- deploy
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
cache:
paths:
- .gradle/wrapper
- .gradle/caches
build:
image: openjdk:8
stage: build
script:
- ./gradlew --console=plain --build-cache assemble
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
- ./gradlew --console=plain --no-daemon assemble fatJar
artifacts:
paths:
- build
- .gradle
- "/builds/jastadd/relational-rags/build/libs/relast-*.jar"
test:
image: openjdk:8
stage: test
script:
- ./gradlew --continue --console=plain --info check
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- build
- .gradle
jar:
image: openjdk:8
stage: jar
script:
- ./gradlew --continue --console=plain --info jar
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- build
- .gradle
artifacts:
paths:
- "/builds/jastadd/*/build/libs/*relast*.jar"
- ./gradlew --console=plain --no-daemon --info test
pages:
image: python:3.7-alpine
......@@ -54,3 +37,27 @@ pages:
- public
only:
- master
- main
publish:
image: openjdk:8
stage: deploy
needs:
- test
script:
- "./gradlew publish"
only:
- master
- main
publish_dev:
image: openjdk:8
stage: deploy
needs:
- test
script:
- "./gradlew setDevVersionForCI"
- "./gradlew publish"
except:
- master
- main
......@@ -23,33 +23,27 @@ This location can be [configured](#build-configuration).
## Build configuration
Currently, the test setup is configured within `build.gradle` using a specialized Gradle task `RelastTest`.
Currently, the test setup is configured within `build.gradle` using a specialized Gradle task `RelastTest` provided by the [preprocessor testing Gradle plugin][preprocessor-testing].
An example configuration might look like:
```groovy
task compileMultipleTest(type: RelastTest) {
relastFiles 'src/test/jastadd/multiple/Part1.relast',
'src/test/jastadd/multiple/Part2.relast',
'src/test/jastadd/multiple/Part3.relast'
relast {
inputFiles = [file('src/test/jastadd/multiple/Part1.relast'),
file('src/test/jastadd/multiple/Part2.relast'),
file('src/test/jastadd/multiple/Part3.relast')]
grammarName = 'src/test/jastadd/multiple/Multiple'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
packageName = 'multiple.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
inputFiles = [file('src/test/jastadd/Utils.jadd')]
}
}
```
The following options are supported, similar to the [command-line options](/../#supported-command-line-options):
| Name | Description | Required | Default |
|-------------------|--------------------------------------------------------------------------------------------------------|--------------------|---------------------|
| `relastFiles` | Input grammar(s). Either one or multiple files separated by comma. | Yes | _none_ |
| `grammarName` | Directory and file prefix for the generated grammar and jrag created by RelAST. | Yes | _none_ |
| `useJastAddNames` | Set to `true` to use accessor names for relations matching JastAdd naming convention. | No | `false` |
| `packageName` | Name of the package for the Java files generated by JastAdd. | Yes (not enforced) | The empty package |
| `moreInputFiles` | Additional files as input for JastAdd. | No | No additional files |
| `resolverHelper` | Set to `true` to generate means for lazy resolving. | No | `false` |
| `jastAddList` | Alternative name for `List` nodes. Will be passed to both RelAST and JastAdd. | No | `List` |
| `serializer` | Name of supported serializer. One of {`jackson`, `jackson-json-pointer`, `jackson-manual-references`}. | No | No serializer |
Please see the [documentation of the plugin][preprocessor-testing] for all options.
## Test files
......@@ -106,3 +100,4 @@ The workflow:
[semantic-versioning]: https://semver.org/
[create-release]: /../-/tags/new
[create-issue]: https://git-st.inf.tu-dresden.de/jastadd/relational-rags/issues/new
[preprocessor-testing]: https://jastadd.pages.st.inf.tu-dresden.de/testing/
......@@ -2,7 +2,7 @@
![RelAST process](relast-process.png)
See [releases page](/../../releases) for the latest version.
See [releases page](/../../releases) for the latest version and <https://jastadd.pages.st.inf.tu-dresden.de/relational-rags/> for more documentation.
The RelAST preprocessor takes a `.relast` file as input comprising AST rules and relations. It produces files that afterwards are processed by JastAdd to generated Java code.
To use it in your project, build the JAR file running
......@@ -52,21 +52,23 @@ Note that you may have to change
## Supported relations
// Directed relations
A.b -> B;
A.b? -> B;
A.bs* -> B;
B <- A.b ;
B <- A.b? ;
B <- A.bs*;
```
// Directed relations
A.b -> B;
A.b? -> B;
A.bs* -> B;
B <- A.b ;
B <- A.b? ;
B <- A.bs*;
// Bidirectional relations
A.b <-> B.a;
A.b <-> B.a?;
A.b <-> B.as*;
A.b? <-> B.a;
A.b? <-> B.a?;
A.b? <-> B.as*;
A.bs* <-> B.a;
A.bs* <-> B.a?;
A.bs* <-> B.as*;
// Bidirectional relations
A.b <-> B.a;
A.b <-> B.a?;
A.b <-> B.as*;
A.b? <-> B.a;
A.b? <-> B.a?;
A.b? <-> B.as*;
A.bs* <-> B.a;
A.bs* <-> B.a?;
A.bs* <-> B.as*;
```
import org.jastadd.relast.plugin.RelastTest
buildscript {
repositories {
maven {
name "gitlab-maven"
url "https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven"
}
}
dependencies {
classpath 'org.jastadd.preprocessor:testing:0.2.14-32'
}
}
import org.jastadd.preprocessor.testing.plugin.PreprocessorPlugin
import org.jastadd.preprocessor.testing.plugin.RelastTest
//file:noinspection HardCodedStringLiteral
plugins {
id 'java'
id 'java-library'
id 'application'
id 'idea'
id 'maven-publish'
id 'org.jastadd' version '1.14.5'
}
apply plugin: 'java'
apply plugin: 'jastadd'
apply plugin: 'application'
apply plugin: "idea"
apply plugin: "org.jastadd.relast.plugin"
apply plugin: PreprocessorPlugin
sourceCompatibility = 1.8
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
mainClassName = 'org.jastadd.relast.compiler.Compiler'
ext {
mainClassName = 'org.jastadd.relast.compiler.Compiler'
}
repositories {
jcenter()
mavenCentral()
maven {
name 'gitlab-maven'
url 'https://git-st.inf.tu-dresden.de/api/v4/groups/jastadd/-/packages/maven'
}
}
group = 'org.jastadd'
apply plugin: 'maven-publish'
buildscript {
repositories.jcenter()
dependencies {
classpath 'org.jastadd:jastaddgradle:1.13.3'
}
}
// set the main class name for `gradle run`
application.mainClass = "${mainClassName}"
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.0'
testCompile 'org.assertj:assertj-core:3.12.1'
compile 'com.fasterxml.jackson.core:jackson-core:2.9.8'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
compile 'org.jastadd:jastadd:2.3.4'
runtime 'org.jastadd:jastadd:2.3.4'
compile group: 'net.sf.beaver', name: 'beaver-rt', version: '0.9.11'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.10.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.10.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation 'org.assertj:assertj-core:3.22.0'
testImplementation 'com.fasterxml.jackson.core:jackson-core:2.13.1'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.13.1'
api 'org.jastadd:jastadd:2.3.5'
api 'net.sf.beaver:beaver-rt:0.9.11'
}
sourceSets {
main {
java.srcDir "src/gen/java"
java.srcDir "buildSrc/gen/java"
}
test {
java.srcDir "src/test/java-gen"
}
}
File genSrc = file('src/gen/java')
File testGenSrc = file('src/test/java-gen')
sourceSets.main.java.srcDir genSrc
sourceSets.test.java.srcDir testGenSrc
idea.module.generatedSourceDirs += genSrc
idea.module.generatedSourceDirs += testGenSrc
def versionFile = 'src/main/resources/RelASTVersion.properties'
def oldProps = new Properties()
try {
def oldProps = new Properties()
file(versionFile).withInputStream { stream -> oldProps.load(stream) }
version = oldProps['version']
} catch (e) {
} catch (ignored) {
// this happens, if either the properties file is not present, or cannot be read from
throw new GradleException("File ${versionFile} not found or unreadable. Aborting.")
}
......@@ -66,13 +81,33 @@ task newVersion() {
}
}
jar {
manifest {
attributes "Main-Class": 'org.jastadd.relast.compiler.Compiler'
task printVersion() {
doLast {
println(version)
}
}
task setDevVersionForCI() {
doFirst {
def props = new Properties()
props['version'] = version + "-$System.env.CI_PIPELINE_IID"
props.store(file(versionFile).newWriter(), null)
}
}
jar.archiveBaseName = 'relast'
task fatJar(type: Jar) {
dependsOn jar
group = "build"
archiveBaseName = 'relast'
archiveAppendix = "fatjar"
from sourceSets.main.output
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes "Main-Class": "${mainClassName}"
}
}
......@@ -80,94 +115,95 @@ jastadd {
configureModuleBuild()
modules {
//noinspection GroovyAssignabilityCheck
module("RelAst") {
java {
basedir "."
include "src/main/**/*.java"
include "src/gen/**/*.java"
}
module('RelAst') {
jastadd {
basedir "src/main/jastadd/"
include "**/*.ast"
include "**/*.jadd"
include "**/*.jrag"
basedir 'src/main/jastadd/'
include '**/*.ast'
include '**/*.jadd'
include '**/*.jrag'
}
scanner {
include "src/main/jastadd/RelAst.flex"
include 'src/main/jastadd/RelAst.flex'
}
parser {
include "src/main/jastadd/Preamble.parser"
include "src/main/jastadd/RelAst.parser"
include 'src/main/jastadd/Preamble.parser'
include 'src/main/jastadd/RelAst.parser'
}
}
}
cleanGen.doFirst {
delete "src/gen/java/org"
delete "src/gen-res/BuildInfo.properties"
delete 'src/gen/'
delete 'src/gen-res/'
}
preprocessParser.doFirst {
args += ["--no-beaver-symbol"]
}
module = "RelAst"
module = 'RelAst'
astPackage = 'org.jastadd.relast.ast'
parser.name = 'RelAstParser'
genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res'
scanner.genDir = 'src/gen/java/org/jastadd/relast/scanner'
parser.genDir = 'src/gen/java/org/jastadd/relast/parser'
scanner.genDir = "src/gen/java/org/jastadd/relast/scanner"
parser.genDir = "src/gen/java/org/jastadd/relast/parser"
jastaddOptions = ["--lineColumnNumbers", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
// default options are: ['--rewrite=cnta', '--safeLazy', '--visitCheck=false', '--cacheCycle=false']
extraJastAddOptions = ['--lineColumnNumbers', '--visitCheck=true']
}
// publish gitlab project
publishing {
publications {
maven(MavenPublication) {
artifact("build/libs/relast-${version}.jar") {
extension 'jar'
}
artifactId = 'relast'
from components.java
}
}
repositories {
maven {
name 'nexus'
url "http://172.22.1.152:8081/repository/" + (project.hasProperty('asSnapshot') ? "maven-snapshots" : "maven-releases/")
credentials {
username project.ext.properties.repoUser
password project.ext.properties.repoPassword
url "https://git-st.inf.tu-dresden.de/api/v4/projects/$System.env.CI_PROJECT_ID/packages/maven"
credentials(HttpHeaderCredentials) {
name = 'Job-Token'
value = System.getenv('CI_JOB_TOKEN')
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
publish.dependsOn jar
}
}
task firstRelationsRun(type: RelastTest) {
relastFiles 'src/test/jastadd/relations/Relations.relast'
relast {
inputFiles = [file('src/test/jastadd/relations/Relations.relast')]
grammarName = 'src/test/jastadd/relations/Relations'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
packageName = 'relations.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd', 'src/test/jastadd/relations/Relations.jrag'
inputFiles = [file('src/test/jastadd/Utils.jadd'),
file('src/test/jastadd/relations/Relations.jrag')]
}
}
task secondRelationsRun(type: RelastTest, dependsOn: firstRelationsRun) {
relastFiles 'src/test/jastadd/relations/Relations.ast'
relast {
inputFiles = [file('src/test/jastadd/relations/Relations.ast')]
grammarName = 'src/test/jastadd/relations/Relations2'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
skipRun = true
packageName = 'ignored'
}
doLast {
delete fileTree('src/test/java-gen/ignored')
......@@ -176,131 +212,198 @@ task secondRelationsRun(type: RelastTest, dependsOn: firstRelationsRun) {
}
task compileConstructorTest(type: RelastTest) {
relastFiles 'src/test/jastadd/constructors/Constructors.relast'
relast {
inputFiles = [file('src/test/jastadd/constructors/Constructors.relast')]
grammarName = 'src/test/jastadd/constructors/Constructors'
noResolverHelper = true
}
jastadd {
packageName = 'constructors.ast'
moreInputFiles 'src/test/jastadd/constructors/Constructors.jrag'
inputFiles = [file('src/test/jastadd/constructors/Constructors.jrag')]
}
}
task compileDefaultNamesTest(type: RelastTest) {
relastFiles 'src/test/jastadd/relations/Relations.relast'
relast {
inputFiles = [file('src/test/jastadd/relations/Relations.relast')]
grammarName = 'src/test/jastadd/relations/Relations3'
useJastAddNames = false
noResolverHelper = true
}
jastadd {
packageName = 'defaultnames.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd', 'src/test/jastadd/relations/Relations.jrag'
inputFiles = [file('src/test/jastadd/Utils.jadd'),
file('src/test/jastadd/relations/Relations.jrag')]
}
}
task compileDefaultNamesResolverTest(type: RelastTest) {
relastFiles 'src/test/jastadd/resolver/Resolver.relast'
relast {
inputFiles = [file('src/test/jastadd/resolver/Resolver.relast')]
grammarName = 'src/test/jastadd/resolver/Resolver2'
resolverHelper = true
useJastAddNames = false
}
jastadd {
packageName = 'defaultnames.resolver.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd',
'src/test/jastadd/resolver/ResolverUtils.jadd',
'src/test/jastadd/resolver/MyRefResolver.jadd'
inputFiles = [file('src/test/jastadd/Utils.jadd'),
file('src/test/jastadd/resolver/ResolverUtils.jadd'),
file('src/test/jastadd/resolver/MyRefResolver.jadd')]
}
}
task compileLowerBoundsTest(type: RelastTest) {
relastFiles 'src/test/jastadd/lowerbounds/LowerBounds.relast'
relast {
inputFiles = [file('src/test/jastadd/lowerbounds/LowerBounds.relast')]
grammarName = 'src/test/jastadd/lowerbounds/LowerBounds'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
packageName = 'lowerbounds.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
inputFiles = [file('src/test/jastadd/Utils.jadd')]
}
}
task compileMultipleTest(type: RelastTest) {
relastFiles 'src/test/jastadd/multiple/Part1.relast',
'src/test/jastadd/multiple/Part2.relast',
'src/test/jastadd/multiple/Part3.relast'
relast {
inputFiles = [file('src/test/jastadd/multiple/Part1.relast'),
file('src/test/jastadd/multiple/Part2.relast'),
file('src/test/jastadd/multiple/Part3.relast')]
grammarName = 'src/test/jastadd/multiple/Multiple'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
packageName = 'multiple.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
inputFiles = [file('src/test/jastadd/Utils.jadd')]
}
}
task compileMultipleMixedTest(type: RelastTest) {
relastFiles 'src/test/jastadd/multiple-mixed/Part1.relast',
'src/test/jastadd/multiple-mixed/Part2.relast',
'src/test/jastadd/multiple-mixed/Part3.relast'
relast {
inputFiles = [file('src/test/jastadd/multiple-mixed/Part1.relast'),
file('src/test/jastadd/multiple-mixed/Part2.relast'),
file('src/test/jastadd/multiple-mixed/Part3.relast')]
grammarName = 'src/test/jastadd/multiple/Multiple'
useJastAddNames = true
noResolverHelper = true
}
jastadd {
packageName = 'mixed.multiple.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
inputFiles = [file('src/test/jastadd/Utils.jadd')]
}
}
task compileResolverTest(type: RelastTest) {
relastFiles 'src/test/jastadd/resolver/Resolver.relast'
relast {
inputFiles = [file('src/test/jastadd/resolver/Resolver.relast')]
grammarName = 'src/test/jastadd/resolver/Resolver'
useJastAddNames = true
resolverHelper = true
}
jastadd {
packageName = 'resolver.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd',
'src/test/jastadd/resolver/ResolverUtils.jadd',
'src/test/jastadd/resolver/MyRefResolver.jadd'
inputFiles = [file('src/test/jastadd/Utils.jadd'),
file('src/test/jastadd/resolver/ResolverUtils.jadd'),
file('src/test/jastadd/resolver/MyRefResolver.jadd')]
}
}
task compileResolver2Test(type: RelastTest) {
relastFiles 'src/test/jastadd/resolver2/Resolver.relast'
relast {
inputFiles = [file('src/test/jastadd/resolver2/Resolver.relast')]
grammarName = 'src/test/jastadd/resolver2/Resolver'
useJastAddNames = true
resolverHelper = true
}
jastadd {
packageName = 'resolver2.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd',
'src/test/jastadd/resolver2/ResolverUtils.jadd',
'src/test/jastadd/resolver2/MyRefResolver.jadd'
inputFiles = [file('src/test/jastadd/Utils.jadd'),
file('src/test/jastadd/resolver2/ResolverUtils.jadd'),
file('src/test/jastadd/resolver2/MyRefResolver.jadd')]
}
}
task compileListNamesTest(type: RelastTest) {
relastFiles 'src/test/jastadd/listnames/ListNames.relast'
relast {
inputFiles = [file('src/test/jastadd/listnames/ListNames.relast')]
grammarName = 'src/test/jastadd/listnames/ListNames'
useJastAddNames = true
jastAddList = 'ListyMcListface'
noResolverHelper = true
listClass = 'java.util.LinkedList'
}
jastadd {
jastAddList = 'ListyMcListface'
packageName = 'listnames.ast'
moreInputFiles 'src/test/jastadd/Utils.jadd'
inputFiles = [file('src/test/jastadd/Utils.jadd')]