Skip to content
Snippets Groups Projects
Commit 4c57f378 authored by Johannes Mey's avatar Johannes Mey
Browse files

separate relast preprocessor from ros2rag

parent f9dc7f4a
No related branches found
No related tags found
No related merge requests found
Pipeline #6490 passed
Model ::= RobotArm ZoneModel ;
ZoneModel ::= <Size:IntPosition> SafetyZone:Zone* ;
Zone ::= Coordinate* ;
RobotArm ::= Joint* EndEffector <_AttributeTestSource:int> /<_AppropriateSpeed:double>/ ; // normally this would be: <AttributeTestSource:int> ;
Joint ::= <Name> <CurrentPosition:IntPosition> ; // normally this would be: <CurrentPosition:IntPosition>
EndEffector : Joint;
Coordinate ::= <Position:IntPosition> ;
...@@ -67,7 +67,7 @@ task relast(type: JavaExec) { ...@@ -67,7 +67,7 @@ task relast(type: JavaExec) {
args = [ args = [
"../libs/relast.jar", "../libs/relast.jar",
"./src/main/jastadd/RelAst.relast", "../relast.preprocessor/src/main/jastadd/RelAst.relast",
"./src/main/jastadd/Ros2Rag.relast", "./src/main/jastadd/Ros2Rag.relast",
"--listClass=java.util.ArrayList", "--listClass=java.util.ArrayList",
"--jastAddList=JastAddList", "--jastAddList=JastAddList",
...@@ -78,7 +78,7 @@ task relast(type: JavaExec) { ...@@ -78,7 +78,7 @@ task relast(type: JavaExec) {
] ]
inputs.files file("../libs/relast.jar"), inputs.files file("../libs/relast.jar"),
file("src/main/jastadd/RelAST.relast"), file("../relast.preprocessor/src/main/jastadd/RelAST.relast"),
file("src/main/jastadd/Ros2Rag.relast") file("src/main/jastadd/Ros2Rag.relast")
outputs.files file("./src/gen/jastadd/Ros2Rag.ast"), outputs.files file("./src/gen/jastadd/Ros2Rag.ast"),
file("src/gen/jastadd/Ros2Rag.jadd"), file("src/gen/jastadd/Ros2Rag.jadd"),
...@@ -93,19 +93,24 @@ jastadd { ...@@ -93,19 +93,24 @@ jastadd {
module("Ros2Rag") { module("Ros2Rag") {
java { java {
basedir "." basedir ".."
include "src/main/**/*.java" include "relast.preprocessor/main/**/*.java"
include "src/gen/**/*.java" include "relast.preprocessor/gen/**/*.java"
include "ros2rag.base/src/main/**/*.java"
include "ros2rag.base/src/gen/**/*.java"
} }
jastadd { jastadd {
basedir "." basedir ".."
include "src/main/jastadd/**/*.ast" include "relast.preprocessor/src/main/jastadd/**/*.ast"
include "src/main/jastadd/**/*.jadd" include "relast.preprocessor/src/main/jastadd/**/*.jadd"
include "src/main/jastadd/**/*.jrag" include "relast.preprocessor/src/main/jastadd/**/*.jrag"
include "src/gen/jastadd/**/*.ast" include "ros2rag.base/src/main/jastadd/**/*.ast"
include "src/gen/jastadd/**/*.jadd" include "ros2rag.base/src/main/jastadd/**/*.jadd"
include "src/gen/jastadd/**/*.jrag" 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"
} }
scanner { scanner {
...@@ -113,9 +118,10 @@ jastadd { ...@@ -113,9 +118,10 @@ jastadd {
} }
parser { parser {
include "src/main/jastadd/Preamble.parser" basedir ".."
include "src/main/jastadd/RelAst.parser" include "ros2rag.base/src/main/jastadd/Preamble.parser"
include "src/main/jastadd/Ros2Rag.parser" include "relast.preprocessor/src/main/jastadd/RelAst.parser"
include "ros2rag.base/src/main/jastadd/Ros2Rag.parser"
} }
} }
} }
......
aspect NameResolution { aspect NameResolution {
refine RefResolverStubs eq ASTNode.globallyResolveTypeDeclByToken(String id) = program().resolveTypeDecl(id);
syn TypeDecl Program.resolveTypeDecl(String name) {
for (TypeDecl decl : typeDecls()) {
if (decl.getName().equals(name)) {
return decl;
}
}
throw new RuntimeException("TypeDecl " + name + " could not be resolved.");
}
refine RefResolverStubs eq ASTNode.globallyResolveTokenComponentByToken(String id) {
// return a TokenComponent. id is of the form 'type_name + "." + token_name'
int dotIndex = id.indexOf(".");
String typeName = id.substring(0, dotIndex);
String tokenName = id.substring(dotIndex + 1);
TypeDecl type = program().resolveTypeDecl(typeName);
// iterate over components and find the matching tokenComponent
for (Component comp : type.getComponentList()) {
if (comp.isTokenComponent() && comp.getName().equals(tokenName)) {
return comp.asTokenComponent();
}
}
System.err.println("Could not resolve TokenComponent '" + id + "'.");
return null;
}
refine RefResolverStubs eq UpdateDefinition.resolveMappingByToken(String id) { refine RefResolverStubs eq UpdateDefinition.resolveMappingByToken(String id) {
// return a MappingDefinition // return a MappingDefinition
for (MappingDefinition mappingDefinition : ros2rag().getMappingDefinitionList()) { for (MappingDefinition mappingDefinition : ros2rag().getMappingDefinitionList()) {
......
aspect Navigation { aspect Navigation {
// --- program --- // --- program ---
inh Program ASTNode.program();
eq Program.getChild().program() = this;
eq Ros2Rag.getChild().program() = getProgram(); eq Ros2Rag.getChild().program() = getProgram();
// --- ros2rag // --- ros2rag
inh Ros2Rag ASTNode.ros2rag(); inh Ros2Rag ASTNode.ros2rag();
eq Ros2Rag.getChild().ros2rag() = this; eq Ros2Rag.getChild().ros2rag() = this;
// --- typeDecls ---
coll java.util.Set<TypeDecl> Program.typeDecls() [new java.util.HashSet<>()] root Program;
TypeDecl contributes this
to Program.typeDecls()
for program();
// --- relations ---
coll java.util.Set<Relation> Program.relations() [new java.util.HashSet<>()] root Program;
Relation contributes this
to Program.relations()
for program();
// --- containingTypeDecl ---
inh TypeDecl Component.containingTypeDecl();
eq TypeDecl.getChild().containingTypeDecl() = this;
// syn boolean RelationComponent.multiplicityOne() = false;
// eq OneRelationComponent.multiplicityOne() = true;
// syn boolean RelationComponent.multiplicityOpt() = false;
// eq OptionalRelationComponent.multiplicityOpt() = true;
// syn boolean RelationComponent.multiplicityMany() = false;
// eq ManyRelationComponent.multiplicityMany() = true;
// --- containedFile ---
inh GrammarFile ASTNode.containedFile();
eq GrammarFile.getChild().containedFile() = this;
// --- isTokenComponent ---
syn boolean Component.isTokenComponent() = false;
eq TokenComponent.isTokenComponent() = true;
// --- asTokenComponent ---
syn TokenComponent Component.asTokenComponent() = null;
eq TokenComponent.asTokenComponent() = this;
} }
...@@ -4,3 +4,4 @@ include 'ros2rag.base' ...@@ -4,3 +4,4 @@ include 'ros2rag.base'
include 'ros2rag.example' include 'ros2rag.example'
include 'ros2rag.senderstub' include 'ros2rag.senderstub'
include 'ros2rag.receiverstub' include 'ros2rag.receiverstub'
include 'relast.preprocessor'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment