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

Renaming ros2rag.{base,tests} to ragconnect.{base,tests}.

- rename nonterminal (M)Ros2Rag to (M)RagConnect, and attribute ros2rag to ragconnect
- rename starter to safety
- make receiverstub, receiverstub not depend on safety
- make tests not depend on common (copied proto files)
parent 68a4ee8e
Pipeline #7514 passed with stages
in 4 minutes and 13 seconds
......@@ -3,7 +3,7 @@ apply plugin: 'application'
sourceCompatibility = 1.8
mainClassName = 'org.jastadd.ros2rag.compiler.Compiler'
mainClassName = 'org.jastadd.ragconnect.compiler.Compiler'
repositories {
jcenter()
......@@ -37,7 +37,7 @@ test {
jar {
manifest {
attributes "Main-Class": 'org.jastadd.ros2rag.compiler.Compiler'
attributes "Main-Class": 'org.jastadd.ragconnect.compiler.Compiler'
}
from {
......@@ -51,47 +51,47 @@ task relast(type: JavaExec) {
doFirst {
delete "src/gen/jastadd/*.ast"
delete "src/gen/jastadd/Ros2Rag.jadd"
delete "src/gen/jastadd/Ros2RagRefResolver.jadd"
delete "src/gen/jastadd/Ros2RagResolverStubs.jrag"
delete "src/gen/jastadd/RagConnect.jadd"
delete "src/gen/jastadd/RagConnectRefResolver.jadd"
delete "src/gen/jastadd/RagConnectResolverStubs.jrag"
mkdir "src/gen/jastadd/"
}
args = [
"../libs/relast.jar",
"../relast.preprocessor/src/main/jastadd/RelAst.relast",
"./src/main/jastadd/Ros2Rag.relast",
"./src/main/jastadd/RagConnect.relast",
"./src/main/jastadd/MustacheNodes.relast",
"--listClass=java.util.ArrayList",
"--jastAddList=JastAddList",
"--useJastAddNames",
"--file",
"--resolverHelper",
"--grammarName=./src/gen/jastadd/Ros2Rag"
"--grammarName=./src/gen/jastadd/RagConnect"
]
inputs.files file("../libs/relast.jar"),
file("../relast.preprocessor/src/main/jastadd/RelAST.relast"),
file("./src/main/jastadd/Ros2Rag.relast")
file("./src/main/jastadd/RagConnect.relast")
file("./src/main/jastadd/MustacheNodes.relast")
outputs.files file("./src/gen/jastadd/Ros2Rag.ast"),
file("./src/gen/jastadd/Ros2Rag.jadd"),
file("./src/gen/jastadd/Ros2RagRefResolver.jadd"),
file('./src/gen/jastadd/Ros2RagResolverStubs.jrag')
outputs.files file("./src/gen/jastadd/RagConnect.ast"),
file("./src/gen/jastadd/RagConnect.jadd"),
file("./src/gen/jastadd/RagConnectRefResolver.jadd"),
file('./src/gen/jastadd/RagConnectResolverStubs.jrag')
}
jastadd {
configureModuleBuild()
modules {
//noinspection GroovyAssignabilityCheck
module("Ros2Rag") {
module("RagConnect") {
java {
basedir ".."
include "relast.preprocessor/main/**/*.java"
include "relast.preprocessor/gen/**/*.java"
include "ros2rag.base/src/main/**/*.java"
include "ros2rag.base/src/gen/**/*.java"
include "ragconnect.base/src/main/**/*.java"
include "ragconnect.base/src/gen/**/*.java"
}
jastadd {
......@@ -99,23 +99,23 @@ jastadd {
include "relast.preprocessor/src/main/jastadd/**/*.ast"
include "relast.preprocessor/src/main/jastadd/**/*.jadd"
include "relast.preprocessor/src/main/jastadd/**/*.jrag"
include "ros2rag.base/src/main/jastadd/**/*.ast"
include "ros2rag.base/src/main/jastadd/**/*.jadd"
include "ros2rag.base/src/main/jastadd/**/*.jrag"
include "ros2rag.base/src/gen/jastadd/**/*.ast"
include "ros2rag.base/src/gen/jastadd/**/*.jadd"
include "ros2rag.base/src/gen/jastadd/**/*.jrag"
include "ragconnect.base/src/main/jastadd/**/*.ast"
include "ragconnect.base/src/main/jastadd/**/*.jadd"
include "ragconnect.base/src/main/jastadd/**/*.jrag"
include "ragconnect.base/src/gen/jastadd/**/*.ast"
include "ragconnect.base/src/gen/jastadd/**/*.jadd"
include "ragconnect.base/src/gen/jastadd/**/*.jrag"
}
scanner {
basedir ".."
include "ros2rag.base/src/main/jastadd/scanner/Header.flex", [-5]
include "ragconnect.base/src/main/jastadd/scanner/Header.flex", [-5]
include "relast.preprocessor/src/main/jastadd/scanner/Preamble.flex", [-4]
include "relast.preprocessor/src/main/jastadd/scanner/Macros.flex", [-3]
include "ros2rag.base/src/main/jastadd/scanner/Macros.flex", [-3]
include "ragconnect.base/src/main/jastadd/scanner/Macros.flex", [-3]
include "relast.preprocessor/src/main/jastadd/scanner/RulesPreamble.flex", [-2]
include "ros2rag.base/src/main/jastadd/scanner/MappingContent.flex", [-1]
include "ros2rag.base/src/main/jastadd/scanner/Keywords.flex"
include "ragconnect.base/src/main/jastadd/scanner/MappingContent.flex", [-1]
include "ragconnect.base/src/main/jastadd/scanner/Keywords.flex"
include "relast.preprocessor/src/main/jastadd/scanner/Keywords.flex"
include "relast.preprocessor/src/main/jastadd/scanner/Symbols.flex", [1]
include "relast.preprocessor/src/main/jastadd/scanner/RulesPostamble.flex", [2]
......@@ -123,8 +123,8 @@ jastadd {
parser {
basedir ".."
include "ros2rag.base/src/main/jastadd/parser/Preamble.parser"
include "ros2rag.base/src/main/jastadd/parser/Ros2Rag.parser"
include "ragconnect.base/src/main/jastadd/parser/Preamble.parser"
include "ragconnect.base/src/main/jastadd/parser/RagConnect.parser"
include "relast.preprocessor/src/main/jastadd/parser/RelAst.parser"
}
}
......@@ -141,18 +141,18 @@ jastadd {
}
module = "Ros2Rag"
module = "RagConnect"
astPackage = 'org.jastadd.ros2rag.ast'
astPackage = 'org.jastadd.ragconnect.ast'
parser.name = 'Ros2RagParser'
parser.name = 'RagConnectParser'
genDir = 'src/gen/java'
buildInfoDir = 'src/gen-res'
scanner.genDir = "src/gen/java/org/jastadd/ros2rag/scanner"
parser.genDir = "src/gen/java/org/jastadd/ros2rag/parser"
scanner.genDir = "src/gen/java/org/jastadd/ragconnect/scanner"
parser.genDir = "src/gen/java/org/jastadd/ragconnect/parser"
jastaddOptions = ["--lineColumnNumbers", "--List=JastAddList", "--safeLazy", "--visitCheck=true", "--rewrite=cnta", "--cache=all"]
}
......
aspect Analysis {
// --- lookupTokenUpdateDefinition ---
inh TokenUpdateDefinition TokenUpdateDefinition.lookupTokenUpdateDefinition(TokenComponent token);
eq Ros2Rag.getUpdateDefinition().lookupTokenUpdateDefinition(TokenComponent token) {
eq RagConnect.getUpdateDefinition().lookupTokenUpdateDefinition(TokenComponent token) {
for (UpdateDefinition def : getUpdateDefinitionList()) {
if (def.isTokenUpdateDefinition() && def.asTokenUpdateDefinition().getToken().equals(token)) {
return def.asTokenUpdateDefinition();
......@@ -12,7 +12,7 @@ aspect Analysis {
// --- lookupDependencyDefinition ---
inh DependencyDefinition DependencyDefinition.lookupDependencyDefinition(TypeDecl source, String id);
eq Ros2Rag.getDependencyDefinition().lookupDependencyDefinition(TypeDecl source, String id) {
eq RagConnect.getDependencyDefinition().lookupDependencyDefinition(TypeDecl source, String id) {
for (DependencyDefinition def : getDependencyDefinitionList()) {
if (def.getID().equals(id) && def.getSource().containingTypeDecl().equals(source)) {
return def;
......
......@@ -3,17 +3,17 @@ import java.util.TreeSet;
import java.util.LinkedList;
aspect Errors {
coll Set<ErrorMessage> Ros2Rag.errors()
coll Set<ErrorMessage> RagConnect.errors()
[new TreeSet<ErrorMessage>()]
root Ros2Rag;
root RagConnect;
ReadFromMqttDefinition contributes error("Read definition already defined for " + getToken().getName())
when isAlreadyDefined()
to Ros2Rag.errors();
to RagConnect.errors();
ReadFromMqttDefinition contributes error("Reading target token must not be an NTA token!")
when getToken().getNTA()
to Ros2Rag.errors();
to RagConnect.errors();
// if first mapping is null, then suitableDefaultMapping() == null
ReadFromMqttDefinition contributes error("No suitable default mapping found for type " +
......@@ -21,32 +21,32 @@ aspect Errors {
? getToken().getJavaTypeUse().prettyPrint()
: getMappingList().get(0).getFromType().prettyPrint()))
when effectiveMappings().get(0) == null
to Ros2Rag.errors();
to RagConnect.errors();
ReadFromMqttDefinition contributes error("to-type of last mapping must be type of the Token!")
when getToken().getJavaTypeUse().prettyPrint().equals(
effectiveMappings().get(effectiveMappings().size() - 1))
to Ros2Rag.errors();
to RagConnect.errors();
WriteToMqttDefinition contributes error("Writing target token must be an NTA token!")
when !getToken().getNTA()
to Ros2Rag.errors();
to RagConnect.errors();
WriteToMqttDefinition contributes error("Write definition already defined for " + getToken().getName())
when isAlreadyDefined()
to Ros2Rag.errors();
to RagConnect.errors();
DependencyDefinition contributes error("Dependency definition already defined for " + getSource().containingTypeDecl().getName() + " with name " + getID())
when isAlreadyDefined()
to Ros2Rag.errors();
to RagConnect.errors();
DependencyDefinition contributes error("The name of a dependency definition must not be equal to a list-node on the source")
when isAlreadyDefinedAsList()
to Ros2Rag.errors();
to RagConnect.errors();
DependencyDefinition contributes error("There must be a write update definition targeting " + getSource().parentTypeypeAndName() + " for dependency definition " + getID())
when targetUpdateDefinition() == null
to Ros2Rag.errors();
to RagConnect.errors();
}
aspect ErrorHelpers {
......
//TypeComponentMustache ;
//rel TypeComponentMustache.TypeComponent -> TypeComponent ;
MRos2Rag ::= ReadDefinition:MReadDefinition* WriteDefinition:MWriteDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*;
MRagConnect ::= ReadDefinition:MReadDefinition* WriteDefinition:MWriteDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*;
abstract MUpdateDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*;
MReadDefinition : MUpdateDefinition;
MWriteDefinition : MUpdateDefinition;
......@@ -11,7 +11,7 @@ MDependencyDefinition;
MTypeComponent;
MTokenComponent;
rel MRos2Rag.Ros2Rag -> Ros2Rag;
rel MRagConnect.RagConnect -> RagConnect;
rel MInnerMappingDefinition.MappingDefinition -> MappingDefinition;
rel MReadDefinition.ReadFromMqttDefinition -> ReadFromMqttDefinition;
rel MWriteDefinition.WriteToMqttDefinition -> WriteToMqttDefinition;
......
......@@ -2,7 +2,7 @@ aspect NameResolution {
refine RefResolverStubs eq UpdateDefinition.resolveMappingByToken(String id, int position) {
// return a MappingDefinition
for (MappingDefinition mappingDefinition : ros2rag().getMappingDefinitionList()) {
for (MappingDefinition mappingDefinition : ragconnect().getMappingDefinitionList()) {
if (mappingDefinition.getID().equals(id)) {
return mappingDefinition;
}
......
aspect Navigation {
// --- program ---
eq Ros2Rag.getChild().program() = getProgram();
eq MRos2Rag.getChild().program() = getRos2Rag().program();
eq RagConnect.getChild().program() = getProgram();
eq MRagConnect.getChild().program() = getRagConnect().program();
// --- ros2rag ---
inh Ros2Rag ASTNode.ros2rag();
eq Ros2Rag.getChild().ros2rag() = this;
eq MRos2Rag.getChild().ros2rag() = getRos2Rag();
// --- ragconnect ---
inh RagConnect ASTNode.ragconnect();
eq RagConnect.getChild().ragconnect() = this;
eq MRagConnect.getChild().ragconnect() = getRagConnect();
// --- containedFile (first equation should be in preprocessor) ---
eq Program.getChild().containedFile() = null;
eq Ros2Rag.getChild().containedFile() = null;
eq RagConnect.getChild().containedFile() = null;
// --- isTypeComponent (should be in preprocessor) ---
syn boolean Component.isTypeComponent() = false;
......@@ -32,9 +32,9 @@ aspect Navigation {
// --- containedFileName (should replace containedFile in preprocessor) ---
inh String ASTNode.containedFileName();
eq GrammarFile.getChild().containedFileName() = getFileName();
eq Ros2Rag.getChild().containedFileName() = getFileName();
eq RagConnect.getChild().containedFileName() = getFileName();
eq Program.getChild().containedFileName() = null;
eq MRos2Rag.getChild().containedFileName() = null;
eq MRagConnect.getChild().containedFileName() = null;
// --- isTokenUpdateDefinition ---
syn boolean UpdateDefinition.isTokenUpdateDefinition() = false;
......@@ -59,7 +59,7 @@ aspect Navigation {
// --- targetUpdateDefinition ---
syn WriteToMqttDefinition DependencyDefinition.targetUpdateDefinition() {
// resolve definition in here, as we do not need resolveMethod in any other place (yet)
for (UpdateDefinition updateDefinition : ros2rag().getUpdateDefinitionList()) {
for (UpdateDefinition updateDefinition : ragconnect().getUpdateDefinitionList()) {
if (updateDefinition.isWriteToMqttDefinition() &&
updateDefinition.asWriteToMqttDefinition().getToken().equals(this.getTarget())) {
return updateDefinition.asWriteToMqttDefinition();
......
Ros2Rag ::= UpdateDefinition* DependencyDefinition* MappingDefinition* Program <FileName> ;
RagConnect ::= UpdateDefinition* DependencyDefinition* MappingDefinition* Program <FileName> ;
abstract UpdateDefinition ::= <AlwaysApply:boolean> ;
......
......@@ -26,15 +26,16 @@ aspect GenerationUtils {
*/
aspect AttributesForMustache {
// --- MRos2Rag ---
eq MRos2Rag.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
eq MRos2Rag.getChild().mqttHandlerField() = mqttHandlerField();
// --- MRagConnect ---
eq MRagConnect.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
eq MRagConnect.getChild().mqttHandlerField() = mqttHandlerField();
eq MRagConnect.getRootTypeComponent(int i).isFirst() = i == 0;
syn String MRos2Rag.mqttHandlerAttribute() = getRos2Rag().mqttHandlerAttribute();
syn String MRos2Rag.mqttHandlerField() = getRos2Rag().mqttHandlerField();
syn String MRos2Rag.mqttSetHostMethod() = getRos2Rag().mqttSetHostMethod();
syn String MRos2Rag.mqttWaitUntilReadyMethod() = getRos2Rag().mqttWaitUntilReadyMethod();
syn String MRos2Rag.mqttCloseMethod() = getRos2Rag().mqttCloseMethod();
syn String MRagConnect.mqttHandlerAttribute() = getRagConnect().mqttHandlerAttribute();
syn String MRagConnect.mqttHandlerField() = getRagConnect().mqttHandlerField();
syn String MRagConnect.mqttSetHostMethod() = getRagConnect().mqttSetHostMethod();
syn String MRagConnect.mqttWaitUntilReadyMethod() = getRagConnect().mqttWaitUntilReadyMethod();
syn String MRagConnect.mqttCloseMethod() = getRagConnect().mqttCloseMethod();
// --- MUpdateDefinition ---
syn String MUpdateDefinition.preemptiveExpectedValue();
......@@ -116,6 +117,7 @@ aspect AttributesForMustache {
syn String MTypeComponent.name() = getTypeComponent().getName();
inh String MTypeComponent.mqttHandlerAttribute();
inh String MTypeComponent.mqttHandlerField();
inh boolean MTypeComponent.isFirst();
// --- MTokenComponent ---
syn String MTokenComponent.parentTypeName() = getTokenComponent().containingTypeDecl().getName();
......@@ -124,9 +126,9 @@ aspect AttributesForMustache {
syn String MTokenComponent.internalName() = getTokenComponent().internalName();
// --- toMustache ---
syn lazy MRos2Rag Ros2Rag.toMustache() {
MRos2Rag result = new MRos2Rag();
result.setRos2Rag(this);
syn lazy MRagConnect RagConnect.toMustache() {
MRagConnect result = new MRagConnect();
result.setRagConnect(this);
for (UpdateDefinition def : getUpdateDefinitionList()) {
if (def.isWriteToMqttDefinition()) {
result.addWriteDefinition(def.asWriteToMqttDefinition().toMustache());
......@@ -216,29 +218,29 @@ aspect AspectGeneration {
syn String DependencyDefinition.internalRelationPrefix() = "_internal_" + getID();
syn String DependencyDefinition.internalTokenName() = getSource().internalName();
syn String Ros2Rag.mqttHandlerAttribute() = "_mqttHandler";
syn String Ros2Rag.mqttHandlerField() = "_mqttHandler";
syn String RagConnect.mqttHandlerAttribute() = "_mqttHandler";
syn String RagConnect.mqttHandlerField() = "_mqttHandler";
syn String Ros2Rag.mqttSetHostMethod() = "MqttSetHost";
syn String Ros2Rag.mqttWaitUntilReadyMethod() = "MqttWaitUntilReady";
syn String Ros2Rag.mqttCloseMethod() = "MqttCloseConnections";
syn String RagConnect.mqttSetHostMethod() = "MqttSetHost";
syn String RagConnect.mqttWaitUntilReadyMethod() = "MqttWaitUntilReady";
syn String RagConnect.mqttCloseMethod() = "MqttCloseConnections";
// naming copy attributes
// --- mqttHandlerAttribute ---
inh String UpdateDefinition.mqttHandlerAttribute();
inh String MappingDefinition.mqttHandlerAttribute();
inh String DependencyDefinition.mqttHandlerAttribute();
eq Ros2Rag.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
eq RagConnect.getChild().mqttHandlerAttribute() = mqttHandlerAttribute();
// --- rootNodeName ---
syn String ASTNode.rootNodeName() = rootNode.getName();
public String Ros2Rag.generateAspect(String rootNodeName) {
public String RagConnect.generateAspect(String rootNodeName) {
rootNode = getProgram().resolveTypeDecl(rootNodeName);
return toMustache().generateAspect();
}
public String MRos2Rag.generateAspect() {
public String MRagConnect.generateAspect() {
StringBuilder sb = new StringBuilder();
com.github.mustachejava.reflect.ReflectionObjectHandler roh = new com.github.mustachejava.reflect.ReflectionObjectHandler() {
@Override
......@@ -257,14 +259,14 @@ aspect AspectGeneration {
};
com.github.mustachejava.DefaultMustacheFactory mf = new com.github.mustachejava.DefaultMustacheFactory();
mf.setObjectHandler(roh);
com.github.mustachejava.Mustache m = mf.compile("ros2rag.mustache");
m.execute(new java.io.PrintWriter(new org.jastadd.ros2rag.compiler.AppendableWriter(sb)), this);
com.github.mustachejava.Mustache m = mf.compile("ragconnect.mustache");
m.execute(new java.io.PrintWriter(new org.jastadd.ragconnect.compiler.AppendableWriter(sb)), this);
return sb.toString();
}
}
aspect RelationGeneration {
syn java.util.List<Relation> Ros2Rag.additionalRelations() {
syn java.util.List<Relation> RagConnect.additionalRelations() {
java.util.List<Relation> result = new java.util.ArrayList<>();
for (DependencyDefinition dd : getDependencyDefinitionList()) {
result.add(dd.getRelationToCreate());
......
aspect DefaultMappings {
private DefaultMappingDefinition Ros2Rag.baseDefaultMappingDefinitionFromBytes(String typeName) {
private DefaultMappingDefinition RagConnect.baseDefaultMappingDefinitionFromBytes(String typeName) {
DefaultMappingDefinition result = new DefaultMappingDefinition();
result.setID("_DefaultBytesTo" + Character.toUpperCase(typeName.charAt(0)) + typeName.substring(1) + "Mapping");
result.setFromType(new JavaArrayMappingDefinitionType(new SimpleJavaTypeUse("byte")));
......@@ -9,7 +9,7 @@ aspect DefaultMappings {
return result;
}
private DefaultMappingDefinition Ros2Rag.baseDefaultMappingDefinitionToBytes(String typeName) {
private DefaultMappingDefinition RagConnect.baseDefaultMappingDefinitionToBytes(String typeName) {
DefaultMappingDefinition result = new DefaultMappingDefinition();
result.setID("_Default" + Character.toUpperCase(typeName.charAt(0)) + typeName.substring(1) + "ToBytesMapping");
result.setFromType(new JavaMappingDefinitionType(new SimpleJavaTypeUse(typeName)));
......@@ -18,85 +18,85 @@ aspect DefaultMappings {
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultBytesToIntMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultBytesToIntMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("int");
result.setContent("return java.nio.ByteBuffer.wrap(bytes).getInt();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultBytesToShortMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultBytesToShortMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("short");
result.setContent("return java.nio.ByteBuffer.wrap(bytes).getShort();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultBytesToLongMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultBytesToLongMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("long");
result.setContent("return java.nio.ByteBuffer.wrap(bytes).getLong();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultBytesToFloatMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultBytesToFloatMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("float");
result.setContent("return java.nio.ByteBuffer.wrap(bytes).getFloat();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultBytesToDoubleMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultBytesToDoubleMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("double");
result.setContent("return java.nio.ByteBuffer.wrap(bytes).getDouble();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultBytesToCharMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultBytesToCharMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("char");
result.setContent("return java.nio.ByteBuffer.wrap(bytes).getChar();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultBytesToStringMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultBytesToStringMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionFromBytes("String");
result.setContent("return new String(bytes);");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultIntToBytesMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultIntToBytesMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionToBytes("int");
result.setContent("return java.nio.ByteBuffer.allocate(4).putInt(input).array();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultShortToBytesMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultShortToBytesMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionToBytes("short");
result.setContent("return java.nio.ByteBuffer.allocate(2).putShort(input).array();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultLongToBytesMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultLongToBytesMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionToBytes("long");
result.setContent("return java.nio.ByteBuffer.allocate(8).putLong(input).array();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultFloatToBytesMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultFloatToBytesMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionToBytes("float");
result.setContent("return java.nio.ByteBuffer.allocate(4).putFloat(input).array();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultDoubleToBytesMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultDoubleToBytesMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionToBytes("double");
result.setContent("return java.nio.ByteBuffer.allocate(8).putDouble(input).array();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultCharToBytesMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultCharToBytesMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionToBytes("char");
result.setContent("return java.nio.ByteBuffer.allocate(2).putChar(input).array();");
return result;
}
syn nta DefaultMappingDefinition Ros2Rag.defaultStringToBytesMapping() {
syn nta DefaultMappingDefinition RagConnect.defaultStringToBytesMapping() {
DefaultMappingDefinition result = baseDefaultMappingDefinitionToBytes("String");
result.setContent("return input.getBytes();");
return result;
......@@ -166,18 +166,18 @@ aspect Mappings {
getMappingList().get(0).getFromType().prettyPrint();
switch(typeName) {
case "int":
case "Integer": return ros2rag().defaultBytesToIntMapping();
case "Integer": return ragconnect().defaultBytesToIntMapping();
case "short":
case "Short": return ros2rag().defaultBytesToShortMapping();
case "Short": return ragconnect().defaultBytesToShortMapping();
case "long":
case "Long": return ros2rag().defaultBytesToLongMapping();
case "Long": return ragconnect().defaultBytesToLongMapping();
case "float":
case "Float": return ros2rag().defaultBytesToFloatMapping();
case "Float": return ragconnect().defaultBytesToFloatMapping();
case "double":
case "Double": return ros2rag().defaultBytesToDoubleMapping();
case "Double": return ragconnect().defaultBytesToDoubleMapping();
case "char":
case "Character": return ros2rag().defaultBytesToCharMapping();
case "String": return ros2rag().defaultBytesToStringMapping();
case "Character": return ragconnect().defaultBytesToCharMapping();
case "String": return ragconnect().defaultBytesToStringMapping();
default: return null;
}
}
......@@ -187,18 +187,18 @@ aspect Mappings {
getMappingList().get(getMappingList().size() - 1).getFromType().prettyPrint();
switch(typeName) {
case "int":
case "Integer": return ros2rag().defaultIntToBytesMapping();
case "Integer": return ragconnect().defaultIntToBytesMapping();
case "short":
case "Short": return ros2rag().defaultShortToBytesMapping();
case "Short": return ragconnect().defaultShortToBytesMapping();
case "long":
case "Long": return ros2rag().defaultLongToBytesMapping();
case "Long": return ragconnect().defaultLongToBytesMapping();
case "float":
case "Float": return ros2rag().defaultFloatToBytesMapping();
case "Float": return ragconnect().defaultFloatToBytesMapping();
case "double":
case "Double": return ros2rag().defaultDoubleToBytesMapping();
case "Double": return ragconnect().defaultDoubleToBytesMapping();
case "char":
case "Character": return ros2rag().defaultCharToBytesMapping();
case "String": return ros2rag().defaultStringToBytesMapping();
case "Character": return ragconnect().defaultCharToBytesMapping();
case "String": return ragconnect().defaultStringToBytesMapping();
default: return null;
}
}
......@@ -208,7 +208,7 @@ aspect Mappings {
eq JavaArrayMappingDefinitionType.isByteArray() = getType().getName().equals("byte");
// --- allMappingDefinitions ---
syn java.util.List<MappingDefinition> Ros2Rag.allMappingDefinitions() {
syn java.util.List<MappingDefinition> RagConnect.allMappingDefinitions() {
java.util.List<MappingDefinition> result = new java.util.ArrayList<>();
getMappingDefinitionList().iterator().forEachRemaining(result::add);
result.add(defaultBytesToIntMapping());
......
%header {:
package org.jastadd.ragconnect.parser;
import org.jastadd.ragconnect.ast.*;
:};
%goal goal;
%goal ragconnect;
Ros2Rag ros2rag
= update_definition.d ros2rag.r {: r.getUpdateDefinitionList().insertChild(d, 0); return r; :}
| dependency_definition.d ros2rag.r {: r.getDependencyDefinitionList().insertChild(d, 0); return r; :}
| mapping_definition.d ros2rag.r {: r.getMappingDefinitionList().insertChild(d, 0); return r; :}
| comment ros2rag.r {: return r; :}
| {: return new Ros2Rag(); :}
RagConnect ragconnect
= update_definition.d ragconnect.r {: r.getUpdateDefinitionList().insertChild(d, 0); return r; :}
| dependency_definition.d ragconnect.r {: r.getDependencyDefinitionList().insertChild(d, 0); return r; :}
| mapping_definition.d ragconnect.r {: r.getMappingDefinitionList().insertChild(d, 0); return r; :}
| comment ragconnect.r {: return r; :}
| {: return new RagConnect(); :}
;
%embed {:
......
package org.jastadd.ros2rag.scanner;
package org.jastadd.ragconnect.scanner;
import org.jastadd.ros2rag.parser.Ros2RagParser.Terminals;
import org.jastadd.ragconnect.parser.RagConnectParser.Terminals;
%%