Commit 13998800 authored by Evgeny Kusmenko's avatar Evgeny Kusmenko
Browse files

Merge branch 'richter-dev' into 'master'

Richter dev

See merge request !2
parents f07c3256 c74789fc
Pipeline #55649 passed with stage
in 1 minute and 27 seconds
......@@ -21,131 +21,124 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- == PROJECT COORDINATES ============================================= -->
<groupId>de.monticore.lang</groupId>
<artifactId>Tagging</artifactId>
<version>0.0.2</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
<properties>
<!-- .. SE-Libraries .................................................. -->
<monticore.version>4.5.4.08.11.2017</monticore.version>
<se-commons.version>1.7.7</se-commons.version>
<mc.grammars.assembly.version>0.0.6-SNAPSHOT</mc.grammars.assembly.version>
<!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version>
<junit.version>4.12</junit.version>
<logback.version>1.1.2</logback.version>
<jscience.version>4.3.1</jscience.version>
<!-- .. Plugins ....................................................... -->
<monticore.plugin>4.5.3-SNAPSHOT</monticore.plugin>
<assembly.plugin>2.5.4</assembly.plugin>
<compiler.plugin>3.3</compiler.plugin>
<source.plugin>2.4</source.plugin>
<shade.plugin>2.4.3</shade.plugin>
<!-- Classifiers -->
<grammars.classifier>grammars</grammars.classifier>
<cli.classifier>cli</cli.classifier>
<!-- .. Misc .......................................................... -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<github.global.server>github</github.global.server>
</properties>
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.7.1</version>
</dependency>
<dependency>
<groupId>de.se_rwth.commons</groupId>
<artifactId>se-commons-logging</artifactId>
<version>${se-commons.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- MontiCore Dependencies -->
<dependency>
<groupId>de.monticore</groupId>
<artifactId>monticore-runtime</artifactId>
<version>${monticore.version}</version>
</dependency>
<dependency>
<groupId>de.monticore</groupId>
<artifactId>monticore-grammar</artifactId>
<version>${monticore.version}</version>
</dependency>
<dependency>
<groupId>de.monticore</groupId>
<artifactId>monticore-grammar</artifactId>
<version>${monticore.version}</version>
<classifier>${grammars.classifier}</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.se_rwth.commons</groupId>
<artifactId>se-commons-groovy</artifactId>
<version>${se-commons.version}</version>
</dependency>
<dependency>
<groupId>org.jscience</groupId>
<artifactId>jscience</artifactId>
<version>4.3.1</version>
</dependency>
<!-- .. Test Libraries ............................................... -->
<!-- .. Test Libraries ............................................... -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.monticore</groupId>
<artifactId>monticore-runtime</artifactId>
<version>${monticore.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.jscience</groupId>
<artifactId>jscience</artifactId>
<version>${jscience.version}</version>
</dependency>
</dependencies>
<!-- == PROJECT BUILD SETTINGS =========================================== -->
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- == PROJECT COORDINATES ============================================= -->
<groupId>de.monticore.lang</groupId>
<artifactId>Tagging</artifactId>
<version>0.0.3-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
<properties>
<!-- .. SE-Libraries .................................................. -->
<monticore.version>5.0.0</monticore.version>
<se-commons.version>1.7.7</se-commons.version>
<mc.grammars.assembly.version>0.0.6-SNAPSHOT</mc.grammars.assembly.version>
<!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version>
<junit.version>4.12</junit.version>
<logback.version>1.1.2</logback.version>
<jscience.version>4.3.1</jscience.version>
<!-- .. Plugins ....................................................... -->
<monticore.plugin>5.0.0</monticore.plugin>
<assembly.plugin>2.5.4</assembly.plugin>
<compiler.plugin>3.3</compiler.plugin>
<source.plugin>2.4</source.plugin>
<shade.plugin>2.4.3</shade.plugin>
<!-- Classifiers -->
<grammars.classifier>grammars</grammars.classifier>
<cli.classifier>cli</cli.classifier>
<!-- .. Misc .......................................................... -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<github.global.server>github</github.global.server>
</properties>
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.7.1</version>
</dependency>
<dependency>
<groupId>de.se_rwth.commons</groupId>
<artifactId>se-commons-logging</artifactId>
<version>${se-commons.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- MontiCore Dependencies -->
<dependency>
<groupId>de.monticore</groupId>
<artifactId>monticore-runtime</artifactId>
<version>${monticore.version}</version>
</dependency>
<dependency>
<groupId>de.monticore</groupId>
<artifactId>monticore-grammar</artifactId>
<version>${monticore.version}</version>
</dependency>
<dependency>
<groupId>de.monticore</groupId>
<artifactId>monticore-grammar</artifactId>
<version>${monticore.version}</version>
<classifier>${grammars.classifier}</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.se_rwth.commons</groupId>
<artifactId>se-commons-groovy</artifactId>
<version>${se-commons.version}</version>
</dependency>
<!-- .. Test Libraries ............................................... -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.monticore</groupId>
<artifactId>monticore-runtime</artifactId>
<version>${monticore.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.jscience</groupId>
<artifactId>jscience</artifactId>
<version>${jscience.version}</version>
</dependency>
</dependencies>
<!-- == PROJECT BUILD SETTINGS =========================================== -->
<build>
<plugins>
......@@ -275,7 +268,7 @@
</execution>
</executions>
</plugin>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
......@@ -299,34 +292,34 @@
<!-- aggregated reports for multi-module projects -->
<aggregate>true</aggregate>
</configuration>
</plugin>
</plugin>
</plugins>
</build>
<!--
<!--
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/external-dependencies</url>
</repository>
<snapshotRepository>
<id>internal.repo</id>
<url>file://${project.build.directory}/external-dependencies</url>
</snapshotRepository>
</distributionManagement>
-->
<!-- == DISTRIBUTION ==================================================== -->
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>Temporary Staging Repository</name>
<url>file://${project.build.directory}/external-dependencies</url>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-releases/</url>
</repository>
<snapshotRepository>
<id>internal.repo</id>
<url>file://${project.build.directory}/external-dependencies</url>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-snapshots/</url>
</snapshotRepository>
</distributionManagement>
-->
<!-- == DISTRIBUTION ==================================================== -->
<distributionManagement>
<repository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-releases/</url>
</repository>
<snapshotRepository>
<id>se-nexus</id>
<url>https://nexus.se.rwth-aachen.de/content/repositories/embeddedmontiarc-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
......@@ -37,9 +37,9 @@ grammar Tagging extends de.monticore.common.Common {
method public String toString(){
String arrayPart = "";
arrayPart += start.isPresent() ? "" + start.get().getValue() : "";
arrayPart += step.isPresent() ? ":" + step.get().getValue() : "";
arrayPart += end.isPresent() ? ":" + end.get().getValue() : "";
arrayPart += getStartOpt().isPresent() ? "" + getStartOpt().get().getValue() : "";
arrayPart += getStepOpt().isPresent() ? ":" + getStepOpt().get().getValue() : "";
arrayPart += getEndOpt().isPresent() ? ":" + getEndOpt().get().getValue() : "";
return name + (arrayPart.equals("") ? "" : "[" + arrayPart + "]");
};
......@@ -47,7 +47,7 @@ grammar Tagging extends de.monticore.common.Common {
QualifiedNameWithArray = parts:( NameWithArray || ".")+;
ast QualifiedNameWithArray =
method public String toString(){
return de.se_rwth.commons.Joiners.DOT.join(getParts());
return de.se_rwth.commons.Joiners.DOT.join(getPartsList());
};
......
......@@ -20,8 +20,11 @@
*/
package de.monticore.lang.tagging._ast;
import java.util.Optional;
public class ASTTagElement extends ASTTagElementTOP {
protected ASTTagElement (String name, String tagValue) {
protected ASTTagElement(String name, Optional<String> tagValue) {
super(name, tagValue);
}
......
......@@ -222,11 +222,6 @@ public class TaggingResolver implements Scope {
return globalScope.resolveLocally(symbolKind);
}
@Override
public Optional<? extends Symbol> resolve(SymbolPredicate symbolPredicate) {
return globalScope.resolve(symbolPredicate);
}
@Override
public <T extends Symbol> Optional<T> resolveDown(String s, SymbolKind symbolKind) {
return globalScope.resolveDown(s, symbolKind);
......@@ -262,12 +257,6 @@ public class TaggingResolver implements Scope {
return globalScope.getLocalSymbols();
}
/** @deprecated */
@Override
public Map<String, Collection<Symbol>> getSymbols() {
return globalScope.getSymbols();
}
@Override
public int getSymbolsSize() {
return globalScope.getSymbolsSize();
......
......@@ -101,8 +101,8 @@ public class TagSchemaGenerator extends GeneratorEngine {
String.format("Could not load tagschema '%s'", tagSchemaLocation.toString()));
List<String> tagTypeNames = new ArrayList<>();
String packageName = Joiners.DOT.join(tagSchemaUnit.getPackage());
List<ASTTagType> tagTypes = tagSchemaUnit.getTagTypes();
String packageName = Joiners.DOT.join(tagSchemaUnit.getPackageList());
List<ASTTagType> tagTypes = tagSchemaUnit.getTagTypeList();
for (ASTTagType tagType : tagTypes) {
generateTagType(tagType, tagSchemaUnit, packageName, symbolScopeMap);
tagTypeNames.add(tagType.getName());
......@@ -129,18 +129,18 @@ public class TagSchemaGenerator extends GeneratorEngine {
protected void generateValuedTagType(ASTValuedTagType valuedTagType, ASTTagSchemaUnit tagSchemaUnit, String packageName, Map<String, String> symbolScopeMap) {
String dataType = null;
boolean isUnit = false;
if (valuedTagType.getBoolean().isPresent()) {
if (valuedTagType.getBooleanOpt().isPresent()) {
dataType = "Boolean";
}
else if (valuedTagType.getNumber().isPresent()) {
else if (valuedTagType.getNumberOpt().isPresent()) {
dataType = "Number";
}
else if (valuedTagType.getString().isPresent()) {
else if (valuedTagType.getStringOpt().isPresent()) {
dataType = "String";
}
else if (valuedTagType.getUnitKind().isPresent()) {
else if (valuedTagType.getUnitKindOpt().isPresent()) {
isUnit = true;
dataType = valuedTagType.getUnitKind().get();
dataType = valuedTagType.getUnitKindOpt().get();
if (!UnitKinds.contains(dataType)) {
Log.error(String.format("Unit kind '%s' is not supported. Currently the following unit kinds are available '%s'",
dataType, UnitKinds.available()), valuedTagType.get_SourcePositionStart());
......@@ -152,7 +152,7 @@ public class TagSchemaGenerator extends GeneratorEngine {
Paths.get(createPackagePath(packageName).toString(), tagSchemaUnit.getName(), valuedTagType.getName() + "Symbol.java"),
tagSchemaUnit, packageName, tagSchemaUnit.getName(), valuedTagType.getName(), dataType, isUnit);
String importSymbols = "de.monticore.lang.montiarc._symboltable.*";
String scopeSymbol = valuedTagType.getScope().get().getScopeIdentifiers().get(0).getScopeName();
String scopeSymbol = valuedTagType.getScopeOpt().get().getScopeIdentifierList().get(0).getScopeName();
String nameScopeType = Log.errorIfNull(symbolScopeMap.get(scopeSymbol), String.format("For the scope symbol '%s' is no scope type defined.", scopeSymbol));
generate("templates.de.monticore.lang.tagschema.ValuedTagTypeCreator",
Paths.get(createPackagePath(packageName).toString(),tagSchemaUnit.getName(), valuedTagType.getName() + "SymbolCreator.java"),
......@@ -174,7 +174,7 @@ public class TagSchemaGenerator extends GeneratorEngine {
Paths.get(createPackagePath(packageName).toString(), tagSchemaUnit.getName(), simpleTagType.getName() + "Symbol.java"),
tagSchemaUnit, packageName, tagSchemaUnit.getName(), simpleTagType.getName());
String importSymbols = "de.monticore.lang.montiarc._symboltable.*";
String scopeSymbol = simpleTagType.getScope().get().getScopeIdentifiers().get(0).getScopeName();
String scopeSymbol = simpleTagType.getScopeOpt().get().getScopeIdentifierList().get(0).getScopeName();
String nameScopeType = Log.errorIfNull(symbolScopeMap.get(scopeSymbol), String.format("For the scope symbol '%s' is no scope type defined.", scopeSymbol));
generate("templates.de.monticore.lang.tagschema.SimpleTagTypeCreator",
Paths.get(createPackagePath(packageName).toString(), tagSchemaUnit.getName(), simpleTagType.getName() + "SymbolCreator.java"),
......
......@@ -22,7 +22,6 @@ package de.monticore.lang.tagging.helper;
import com.google.common.collect.Lists;
import de.monticore.lang.tagging._ast.*;
import de.monticore.literals.literals._ast.ASTIntLiteral;
import java.util.ArrayList;
import java.util.Collection;
......@@ -36,14 +35,14 @@ public class RangeFixer {
public static void fixTaggingUnit(ASTTaggingUnit astTaggingUnit) {
//Replace all range syntax scopes with expanded versions
astTaggingUnit.getTagBody().getTags()
astTaggingUnit.getTagBody().getTagList()
.forEach(tag -> {
List<ASTScope> fixedScopes = tag.getScopes().stream()
List<ASTScope> fixedScopes = tag.getScopeList().stream()
.map(RangeFixer::expandScopeWithRange)
.flatMap(Collection::stream)
.collect(Collectors.toList());
tag.setScopes(fixedScopes);
tag.setScopeList(fixedScopes);
});
}
......@@ -52,22 +51,22 @@ public class RangeFixer {
ASTNameScope nameScope = (ASTNameScope) scope;
List<ASTQualifiedNameWithArray> qualifiedNames = new ArrayList<>();
//add empty start name
qualifiedNames.add(ASTQualifiedNameWithArray.getBuilder().build());
qualifiedNames.add(TaggingMill.qualifiedNameWithArrayBuilder().build());
for (ASTNameWithArray part : nameScope.getQualifiedName().getParts()) {
for (ASTNameWithArray part : nameScope.getQualifiedName().getPartsList()) {
List<ASTNameWithArray> expandedParts = expandRangeInPart(part);
List<ASTQualifiedNameWithArray> expandedNames = new ArrayList<>();
for (ASTNameWithArray ep : expandedParts) {
for (ASTQualifiedNameWithArray name : qualifiedNames) {
ASTQualifiedNameWithArray tmpName = name.deepClone();
tmpName.getParts().add(ep);
tmpName.getPartsList().add(ep);
expandedNames.add(tmpName);
}
}
qualifiedNames = expandedNames;
}
return qualifiedNames.stream().map(name -> ASTNameScope.getBuilder().qualifiedName(name).build()).collect(Collectors.toList());
return qualifiedNames.stream().map(name -> TaggingMill.nameScopeBuilder().setQualifiedName(name).build()).collect(Collectors.toList());
} else {
return Lists.newArrayList(scope);
......@@ -76,20 +75,20 @@ public class RangeFixer {
public static List<ASTNameWithArray> expandRangeInPart(ASTNameWithArray part) {
//Not a range
if (!part.getStart().isPresent() || !part.getEnd().isPresent()) {
if (!part.getStartOpt().isPresent() || !part.getEndOpt().isPresent()) {
return Lists.newArrayList(part);
}
List<ASTNameWithArray> result = new ArrayList<>();
int step = part.getStep().isPresent() ? part.getStep().get().getValue() : 1;
int start = part.getStart().get().getValue();
int end = part.getEnd().get().getValue();
int step = part.getStepOpt().isPresent() ? part.getStepOpt().get().getValue() : 1;
int start = part.getStartOpt().get().getValue();
int end = part.getEndOpt().get().getValue();
for (int i = start; i <= end; i += step) {
ASTNameWithArray tmpNameWithArray = ASTNameWithArray.getBuilder()
.name(part.getName())
.start(ASTIntLiteral.getBuilder().source("" + i).build())
ASTNameWithArray tmpNameWithArray = TaggingMill.nameWithArrayBuilder()
.setName(part.getName())
.setStart(TaggingMill.intLiteralBuilder().setSource("" + i).build())
.build();
result.add(tmpNameWithArray);
}
......
......@@ -20,6 +20,8 @@
*/
package de.monticore.lang.tagschema._ast;
import java.util.Optional;
/**
* Created by MichaelvonWenckstern on 28.06.2016.
*/
......@@ -28,8 +30,8 @@ public class ASTComplexTagType extends ASTComplexTagTypeTOP {
super();
}
public ASTComplexTagType (String name, ASTScope scope, String complexTagDef) {
super(name, scope, complexTagDef);
public ASTComplexTagType(String name, Optional<ASTScope> scope, String complexTag) {
super(name, scope, complexTag);
}
public void setComplexTag(String complexTag) {
......
......@@ -20,44 +20,44 @@
*/
package de.monticore.lang.tagschema._ast;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
/**
* Created by MichaelvonWenckstern on 15.06.2016.
*/
public class ASTEnumeratedTagType extends ASTEnumeratedTagTypeTOP {
protected ASTEnumeratedTagType() {
super();
}
protected ASTEnumeratedTagType() {
super();
}
protected Set<String> enumValues = new LinkedHashSet<>();
protected Set<String> enumValues = new LinkedHashSet<>();
protected ASTEnumeratedTagType (String name, String enumText, ASTScope scope) {
super(name, enumText, scope);
}
protected ASTEnumeratedTagType(String name, String enumText, Optional<ASTScope> scope) {
super(name, enumText, scope);
this.enumValues = enumValues;
}
public void setEnumText(String enumText) {
if (enumText != null) {
if (enumText.startsWith("[")) {
enumText = enumText.substring(1);
}
if (enumText.endsWith("]")) {
enumText = enumText.substring(0, enumText.length() - 1);
}
enumText = enumText.trim();
// TODO fix: now it also splits BC and D in A | "BC|D" | X
String vs[] = enumText.split("\\|");
for (String v : vs) {
enumValues.add(v.trim());
}
public void setEnumText(String enumText) {
if (enumText != null) {
if (enumText.startsWith("[")) {
enumText = enumText.substring(1);
}
if (enumText.endsWith("]")) {
enumText = enumText.substring(0, enumText.length() - 1);
}
enumText = enumText.trim();
// TODO fix: now it also splits BC and D in A | "BC|D" | X
String vs[] = enumText.split("\\|");
for (String v : vs) {
enumValues.add(v.trim());
}
}
super.setEnumText(enumText);
}
super.setEnumText(enumText);
}
public Set<String> getEnumValues() {
return enumValues;
}