Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
JastAdd
RagConnect
Commits
79766203
Commit
79766203
authored
Jun 03, 2021
by
René Schöne
Browse files
Merge branch 'release-0.3.1' into 'master'
Version 0.3.1 See merge request
!8
parents
1f7396a9
3f1eb2a9
Pipeline
#11757
passed with stages
in 6 minutes and 17 seconds
Changes
56
Pipelines
2
Show whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
79766203
...
...
@@ -32,7 +32,7 @@ test:
image
:
openjdk:11
stage
:
test
services
:
-
name
:
"
eclipse-mosquitto:1.6
.9
"
-
name
:
"
eclipse-mosquitto:1.6"
alias
:
"
mqtt"
needs
:
-
build
...
...
.gitmodules
View file @
79766203
[submodule "relast-preprocessor"]
path = relast-preprocessor
url = ../relast-preprocessor.git
branch = jastadd-fix-inc-param-debug
[submodule "ragconnect.base/src/main/jastadd/mustache"]
path = ragconnect.base/src/main/jastadd/mustache
url = ../mustache
branch = develop
libs/jastadd2.jar
0 → 100644
View file @
79766203
File added
pages/docs/changelog.md
0 → 100644
View file @
79766203
# Changelog
## 0.3.1
-
Full support for incremental dependency tracking
-
Full support for subtree endpoint definitions (
[
#9
](
https://git-st.inf.tu-dresden.de/jastadd/ragconnect/-/issues/9
)
)
-
Internal: Use updated gradle plugin for tests (
[
#18
](
https://git-st.inf.tu-dresden.de/jastadd/ragconnect/-/issues/18
)
)
-
Bugfix
[
#22
](
https://git-st.inf.tu-dresden.de/jastadd/ragconnect/-/issues/22
)
: Correct handling of malformed URIs passed when connecting an endpoint
-
Bugfix
[
#23
](
https://git-st.inf.tu-dresden.de/jastadd/ragconnect/-/issues/23
)
: Correct handling of OptComponents as endpoints
-
Bugfix
[
#27
](
https://git-st.inf.tu-dresden.de/jastadd/ragconnect/-/issues/27
)
: Correctly handle whitespaces in grammars
## 0.3.0
-
Added
[
API documentation
](
ragdoc/index.html
)
to documentation
-
Add methods to
`disconnect`
an endpoint
-
Internal: PoC for incremental dependency tracking and subtree endpoint definitions (
[
#14
](
https://git-st.inf.tu-dresden.de/jastadd/ragconnect/-/issues/14
)
)
-
Bugfix
[
#17
](
https://git-st.inf.tu-dresden.de/jastadd/ragconnect/-/issues/17
)
: Added missing support for
`boolean`
pages/mkdocs.yml
View file @
79766203
...
...
@@ -5,6 +5,7 @@ nav:
-
inner-workings.md
-
using.md
-
extending.md
-
changelog.md
-
API documentation
:
ragdoc/index.html
theme
:
name
:
readthedocs
...
...
ragconnect.base/build.gradle
View file @
79766203
...
...
@@ -27,11 +27,9 @@ repositories {
dependencies
{
implementation
project
(
':relast-preprocessor'
)
implementation
group:
'org.apache.logging.log4j'
,
name:
'log4j-api'
,
version:
"${log4j_version}"
implementation
group:
'org.apache.logging.log4j'
,
name:
'log4j-core'
,
version:
"${log4j_version}"
implementation
group:
'org.apache.logging.log4j'
,
name:
'log4j-jul'
,
version:
"${log4j_version}"
implementation
group:
'com.github.spullara.mustache.java'
,
name:
'compiler'
,
version:
"${mustache_java_version}"
runtimeOnly
group:
'org.jastadd'
,
name:
'jastadd'
,
version:
'2.3.5'
// runtimeOnly group: 'org.jastadd', name: 'jastadd', version: '2.3.5'
runtimeOnly
fileTree
(
include:
[
'jastadd2.jar'
],
dir:
'../libs'
)
api
group:
'net.sf.beaver'
,
name:
'beaver-rt'
,
version:
'0.9.11'
}
...
...
@@ -67,14 +65,12 @@ idea.module.generatedSourceDirs += genSrc
jar
{
manifest
{
attributes
"Main-Class"
:
'org.jastadd.ragconnect.compiler.Compiler'
// Log4J + Java 11 compatibility, see https://stackoverflow.com/q/53049346/2493208
attributes
"Multi-Release"
:
true
}
from
{
configurations
.
runtimeClasspath
.
collect
{
it
.
isDirectory
()
?
it
:
zipTree
(
it
)
}
}
duplicatesStrategy
=
DuplicatesStrategy
.
EXCLUDE
archiveBaseName
=
'ragconnect'
}
...
...
@@ -82,7 +78,7 @@ jar {
File
preprocessorGrammar
=
file
(
'../relast-preprocessor/src/main/jastadd/RelAst.relast'
)
File
ragConnectGrammar
=
file
(
'./src/main/jastadd/RagConnect.relast'
)
File
intermediateGrammar
=
file
(
'./src/main/jastadd/intermediate/MustacheNodes.relast'
)
File
mustacheGrammar
=
file
(
'./src/main/jastadd/mustache/Mustache.relast'
)
File
mustacheGrammar
=
file
(
'.
./relast-preprocessor
/src/main/jastadd/mustache/Mustache.relast'
)
task
relast
(
type:
JavaExec
)
{
group
=
'Build'
main
=
"-jar"
...
...
@@ -224,3 +220,4 @@ publishing {
}
publish
.
dependsOn
jar
jar
.
dependsOn
":relast-preprocessor:jar"
ragconnect.base/src/main/jastadd/Analysis.jrag
View file @
79766203
aspect Analysis {
// --- lookupTokenEndpointDefinition ---
inh java.util.List<TokenEndpointDefinition> TokenEndpointDefinition.lookupTokenEndpointDefinitions(TokenComponent token);
eq RagConnect.get
EndpointDefinition
().lookupTokenEndpointDefinitions(TokenComponent token) = lookupTokenEndpointDefinitions(token);
eq RagConnect.get
ConnectSpecificationFile
().lookupTokenEndpointDefinitions(TokenComponent token) = lookupTokenEndpointDefinitions(token);
syn java.util.List<TokenEndpointDefinition> RagConnect.lookupTokenEndpointDefinitions(TokenComponent token) {
java.util.List<TokenEndpointDefinition> result = new java.util.ArrayList<>();
for (EndpointDefinition def :
get
EndpointDefinitionList()) {
for (EndpointDefinition def :
all
EndpointDefinitionList()) {
if (def.isTokenEndpointDefinition() && def.asTokenEndpointDefinition().getToken().equals(token)) {
result.add(def.asTokenEndpointDefinition());
}
...
...
@@ -14,10 +14,10 @@ aspect Analysis {
// --- lookupTypeEndpointDefinition ---
inh java.util.List<TypeEndpointDefinition> TypeEndpointDefinition.lookupTypeEndpointDefinitions(TypeComponent type);
eq RagConnect.get
EndpointDefinition
().lookupTypeEndpointDefinitions(TypeComponent type) = lookupTypeEndpointDefinitions(type);
eq RagConnect.get
ConnectSpecificationFile
().lookupTypeEndpointDefinitions(TypeComponent type) = lookupTypeEndpointDefinitions(type);
syn java.util.List<TypeEndpointDefinition> RagConnect.lookupTypeEndpointDefinitions(TypeComponent type) {
java.util.List<TypeEndpointDefinition> result = new java.util.ArrayList<>();
for (EndpointDefinition def :
get
EndpointDefinitionList()) {
for (EndpointDefinition def :
all
EndpointDefinitionList()) {
if (def.isTypeEndpointDefinition() && def.asTypeEndpointDefinition().getType().equals(type)) {
result.add(def.asTypeEndpointDefinition());
}
...
...
@@ -27,8 +27,8 @@ aspect Analysis {
// --- lookupDependencyDefinition ---
inh DependencyDefinition DependencyDefinition.lookupDependencyDefinition(TypeDecl source, String id);
eq RagConnect.get
DependencyDefinition
().lookupDependencyDefinition(TypeDecl source, String id) {
for (DependencyDefinition def :
get
DependencyDefinitionList()) {
eq RagConnect.get
ConnectSpecificationFile
().lookupDependencyDefinition(TypeDecl source, String id) {
for (DependencyDefinition def :
all
DependencyDefinitionList()) {
if (def.getID().equals(id) && def.getSource().containingTypeDecl().equals(source)) {
return def;
}
...
...
ragconnect.base/src/main/jastadd/Configuration.jadd
View file @
79766203
aspect Configuration {
public static boolean ASTNode.loggingEnabledForReads = false;
public static boolean ASTNode.loggingEnabledForWrites = false;
public static boolean ASTNode.loggingEnabledForIncremental = false;
public static TypeDecl ASTNode.rootNode;
public static boolean ASTNode.usesMqtt;
public static boolean ASTNode.usesRest;
public static boolean ASTNode.incrementalOptionActive;
public static boolean ASTNode.experimentalJastAdd329;
}
ragconnect.base/src/main/jastadd/NameResolution.jrag
View file @
79766203
...
...
@@ -2,7 +2,7 @@ aspect NameResolution {
refine RefResolverStubs eq EndpointDefinition.resolveMappingByToken(String id, int position) {
// return a MappingDefinition
for (MappingDefinition mappingDefinition : ragconnect().
get
MappingDefinitionList()) {
for (MappingDefinition mappingDefinition : ragconnect().
all
MappingDefinitionList()) {
if (mappingDefinition.getID().equals(id)) {
return mappingDefinition;
}
...
...
ragconnect.base/src/main/jastadd/Navigation.jrag
View file @
79766203
aspect Navigation {
import java.util.List;
import java.util.ArrayList;
aspect RagConnectNavigation {
// --- program ---
eq RagConnect.getChild().program() = getProgram();
...
...
@@ -9,15 +12,54 @@ aspect Navigation {
eq RagConnect.getChild().ragconnect() = this;
eq MRagConnect.getChild().ragconnect() = getRagConnect();
// --- containedConnectSpecification ---
inh ConnectSpecification ASTNode.containedConnectSpecification();
eq RagConnect.getChild().containedConnectSpecification() = null;
eq MRagConnect.getChild().containedConnectSpecification() = null;
eq Document.getChild().containedConnectSpecification() = null;
eq Program.getChild().containedConnectSpecification() = null;
eq ConnectSpecification.getChild().containedConnectSpecification() = this;
// --- containedFile
eq Grammar.getChild().containedFile() = null;
eq RagConnect.getChild().containedFile() = null;
eq MRagConnect.getChild().containedFile() = null;
// --- containedFileName ---
eq Grammar.getChild().containedFileName() = null; // should be in PP
eq RagConnect.getChild().containedFileName() = getFileName();
eq MRagConnect.getChild().containedFileName() = null;
eq ConnectSpecificationFile.containedFileName() = getFileName();
refine Navigation eq ASTNode.containedFileName() {
if (containedFile() == null) {
return containedConnectSpecification().containedFileName();
}
return refined();
// return containedFile().getFileName();
}
//--- allEndpointDefinitionList ---
syn List<EndpointDefinition> RagConnect.allEndpointDefinitionList() {
List<EndpointDefinition> result = new ArrayList<>();
for (var spec : getConnectSpecificationFileList()) {
spec.getEndpointDefinitionList().forEach(result::add);
}
return result;
}
//--- allDependencyDefinitionList ---
syn List<DependencyDefinition> RagConnect.allDependencyDefinitionList() {
List<DependencyDefinition> result = new ArrayList<>();
for (var spec : getConnectSpecificationFileList()) {
spec.getDependencyDefinitionList().forEach(result::add);
}
return result;
}
//--- allMappingDefinitionList ---
syn List<MappingDefinition> RagConnect.allMappingDefinitionList() {
List<MappingDefinition> result = new ArrayList<>();
for (var spec : getConnectSpecificationFileList()) {
spec.getMappingDefinitionList().forEach(result::add);
}
return result;
}
// --- isTokenEndpointDefinition ---
syn boolean EndpointDefinition.isTokenEndpointDefinition() = false;
...
...
@@ -70,7 +112,7 @@ aspect Navigation {
// --- targetEndpointDefinition ---
syn EndpointDefinition DependencyDefinition.targetEndpointDefinition() {
// resolve definition in here, as we do not need resolveMethod in any other place (yet)
for (EndpointDefinition endpointDefinition : ragconnect().
get
EndpointDefinitionList()) {
for (EndpointDefinition endpointDefinition : ragconnect().
all
EndpointDefinitionList()) {
if (endpointDefinition.isSendTokenEndpointDefinition() &&
endpointDefinition.asSendTokenEndpointDefinition().getToken().equals(this.getTarget())) {
return endpointDefinition;
...
...
@@ -96,4 +138,7 @@ aspect Navigation {
// --- rootTypeComponents ---
syn JastAddList<MTypeComponent> MHandler.rootTypeComponents() = mragconnect().getRootTypeComponents();
// --- isListComponent --- (defined in PP, but only on TypeComponent)
syn boolean Component.isListComponent() = false;
}
ragconnect.base/src/main/jastadd/RagConnect.relast
View file @
79766203
RagConnect ::= EndpointDefinition* DependencyDefinition* MappingDefinition* Program <FileName> ;
RagConnect ::= ConnectSpecificationFile* Program ;
abstract ConnectSpecification ::= EndpointDefinition* DependencyDefinition* MappingDefinition* ;
ConnectSpecificationFile : ConnectSpecification ::= <FileName> ;
abstract EndpointDefinition ::= <AlwaysApply:boolean> ;
...
...
ragconnect.base/src/main/jastadd/intermediate/Generation.jadd
View file @
79766203
...
...
@@ -62,12 +62,17 @@ aspect AttributesForMustache {
syn String MEndpointDefinition.lastDefinitionToType() = lastDefinition().toType();
syn String MEndpointDefinition.lastResult() = lastDefinition().outputVarName();
syn String MEndpointDefinition.condition() {
// TODO probably, this has to be structured in a better way
if (lastDefinition().mappingDef().getToType().isArray()) {
return "java.util.Arrays.equals(" + preemptiveExpectedValue() + ", " + lastResult() + ")";
}
if (endpointDef().isTokenEndpointDefinition() && token().isPrimitiveType() && lastDefinition().mappingDef().getToType().isPrimitiveType()) {
return preemptiveExpectedValue() + " == " + lastResult();
}
if (endpointDef().isTypeEndpointDefinition() && type().isOptComponent()) {
// use "hasX()" instead of "getX() != null" for optionals
return "has" + typeName() + "()" + " && " + preemptiveExpectedValue() + ".equals(" + lastResult() + ")";
}
if (lastDefinition().mappingDef().getToType().isPrimitiveType() || lastDefinition().mappingDef().isDefaultMappingDefinition()) {
return preemptiveExpectedValue() + " != null && " + preemptiveExpectedValue() + ".equals(" + lastResult() + ")";
}
...
...
@@ -172,7 +177,7 @@ aspect AttributesForMustache {
syn lazy MRagConnect RagConnect.toMustache() {
MRagConnect result = new MRagConnect();
result.setRagConnect(this);
for (EndpointDefinition def :
get
EndpointDefinitionList()) {
for (EndpointDefinition def :
all
EndpointDefinitionList()) {
if (def.isReceiveTokenEndpointDefinition()) {
result.addTokenReceiveDefinition(def.asReceiveTokenEndpointDefinition().toMustache());
} else if (def.isSendTokenEndpointDefinition()) {
...
...
@@ -188,7 +193,7 @@ aspect AttributesForMustache {
for (MappingDefinition def : allMappingDefinitions()) {
result.addMappingDefinition(def.toMustache());
}
for (DependencyDefinition def :
get
DependencyDefinitionList()) {
for (DependencyDefinition def :
all
DependencyDefinitionList()) {
result.addDependencyDefinition(def.toMustache());
}
for (TokenComponent token : getProgram().allTokenComponents()) {
...
...
@@ -311,7 +316,7 @@ aspect AspectGeneration {
aspect RelationGeneration {
syn java.util.List<Relation> RagConnect.additionalRelations() {
java.util.List<Relation> result = new java.util.ArrayList<>();
for (DependencyDefinition dd :
get
DependencyDefinitionList()) {
for (DependencyDefinition dd :
all
DependencyDefinitionList()) {
result.add(dd.getRelationToCreate());
}
return result;
...
...
ragconnect.base/src/main/jastadd/intermediate/Mappings.jrag
View file @
79766203
...
...
@@ -298,7 +298,7 @@ aspect Mappings {
syn java.util.List<MappingDefinition> RagConnect.allMappingDefinitions() {
java.util.List<MappingDefinition> result = new java.util.ArrayList<>();
// user-defined mappings
get
MappingDefinitionList().iterator().forEachRemaining(result::add);
all
MappingDefinitionList().iterator().forEachRemaining(result::add);
// byte[] <-> primitive conversion
result.add(defaultBytesToBooleanMapping());
result.add(defaultBytesToIntMapping());
...
...
ragconnect.base/src/main/jastadd/intermediate2mustache/MustacheNodesToYAML.jrag
View file @
79766203
...
...
@@ -206,5 +206,5 @@ aspect Navigation {
eq Document.getChild().program() = null;
eq Document.getChild().ragconnect() = null;
eq Document.getChild().containedFile() = null;
eq Document.
getChild().
containedFileName() = getFileName();
eq Document.containedFileName() = getFileName();
}
mustache
@
c10bed0d
Compare
c10bed0d
...
c10bed0d
Subproject commit c10bed0d03e3fa18b8133ce1de48de7646899615
ragconnect.base/src/main/jastadd/parser/Preamble.parser
View file @
79766203
...
...
@@ -4,4 +4,4 @@ import org.jastadd.ragconnect.ast.*;
:};
%
goal
goal
;
%
goal
rag
connect
;
%
goal
connect
_specification_file
;
ragconnect.base/src/main/jastadd/parser/RagConnect.parser
View file @
79766203
RagConnect ragconnect
= endpoint_definition.d ragconnect.r {: r.getEndpointDefinitionList().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(); :}
ConnectSpecificationFile connect_specification_file
= endpoint_definition.d connect_specification_file.r
{:
r.getEndpointDefinitionList().insertChild(d, 0); return r;
:}
| dependency_definition.d connect_specification_file.r
{:
r.getDependencyDefinitionList().insertChild(d, 0); return r;
:}
| mapping_definition.d connect_specification_file.r
{:
r.getMappingDefinitionList().insertChild(d, 0); return r;
:}
| comment connect_specification_file.r
{:
return r;
:}
| {: return new ConnectSpecificationFile(); :}
;
%embed {:
...
...
ragconnect.base/src/main/java/org/jastadd/ragconnect/compiler/Compiler.java
View file @
79766203
...
...
@@ -3,11 +3,11 @@ package org.jastadd.ragconnect.compiler;
import
beaver.Parser
;
import
org.jastadd.option.BooleanOption
;
import
org.jastadd.option.ValueOption
;
import
org.jastadd.relast.compiler.AbstractCompiler
;
import
org.jastadd.relast.compiler.CompilerException
;
import
org.jastadd.ragconnect.ast.*
;
import
org.jastadd.ragconnect.parser.RagConnectParser
;
import
org.jastadd.ragconnect.scanner.RagConnectScanner
;
import
org.jastadd.relast.compiler.AbstractCompiler
;
import
org.jastadd.relast.compiler.CompilerException
;
import
java.io.*
;
import
java.nio.file.Files
;
...
...
@@ -15,6 +15,8 @@ import java.nio.file.Path;
import
java.nio.file.Paths
;
import
java.nio.file.StandardCopyOption
;
import
java.util.*
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
public
class
Compiler
extends
AbstractCompiler
{
...
...
@@ -25,10 +27,14 @@ public class Compiler extends AbstractCompiler {
private
BooleanOption
optionVerbose
;
private
BooleanOption
optionLogReads
;
private
BooleanOption
optionLogWrites
;
private
BooleanOption
optionLogIncremental
;
private
BooleanOption
optionExperimentalJastAdd329
;
private
static
final
String
OPTION_PROTOCOL_MQTT
=
"mqtt"
;
private
static
final
String
OPTION_PROTOCOL_REST
=
"rest"
;
private
final
static
Logger
LOGGER
=
Logger
.
getLogger
(
Compiler
.
class
.
getName
());
public
Compiler
()
{
super
(
"ragconnect"
,
true
);
}
...
...
@@ -43,8 +49,11 @@ public class Compiler extends AbstractCompiler {
getConfiguration
().
printHelp
(
System
.
out
);
return
0
;
}
if
(
optionVerbose
.
value
())
{
LOGGER
.
setLevel
(
Level
.
FINE
);
}
printMessage
(
"Running RagConnect "
+
readVersion
());
LOGGER
.
info
(()
->
"Running RagConnect "
+
readVersion
());
if
(!
getConfiguration
().
outputDir
().
exists
())
{
try
{
...
...
@@ -61,10 +70,11 @@ public class Compiler extends AbstractCompiler {
RagConnect
ragConnect
=
parseProgram
(
getConfiguration
().
getFiles
());
if
(!
ragConnect
.
errors
().
isEmpty
())
{
S
ystem
.
err
.
println
(
"Errors:"
);
S
tringBuilder
sb
=
new
StringBuilder
(
"Errors:
\n
"
);
for
(
ErrorMessage
e
:
ragConnect
.
errors
())
{
System
.
err
.
println
(
e
);
sb
.
append
(
e
).
append
(
"\n"
);
}
LOGGER
.
severe
(
sb:
:
toString
);
System
.
exit
(
1
);
}
...
...
@@ -76,7 +86,7 @@ public class Compiler extends AbstractCompiler {
return
0
;
}
printMessag
e
(
"Writing output files"
);
LOGGER
.
fin
e
(
"Writing output files"
);
final
List
<
String
>
handlers
=
new
ArrayList
<>();
if
(
ASTNode
.
usesMqtt
)
{
handlers
.
add
(
"MqttHandler.jadd"
);
...
...
@@ -107,12 +117,11 @@ public class Compiler extends AbstractCompiler {
}
public
static
void
main
(
String
[]
args
)
{
System
.
setProperty
(
"java.util.logging.manager"
,
"org.apache.logging.log4j.jul.LogManager"
);
System
.
setProperty
(
"mustache.debug"
,
"true"
);
try
{
new
Compiler
().
run
(
args
);
}
catch
(
CompilerException
e
)
{
e
.
printStackTrace
(
);
LOGGER
.
log
(
Level
.
SEVERE
,
e
.
getMessage
(),
e
);
System
.
exit
(
1
);
}
}
...
...
@@ -137,12 +146,6 @@ public class Compiler extends AbstractCompiler {
}
}
private
void
printMessage
(
String
message
)
{
if
(
optionVerbose
.
value
())
{
System
.
out
.
println
(
message
);
}
}
private
void
writeToFile
(
Path
path
,
String
str
)
throws
CompilerException
{
try
(
BufferedWriter
writer
=
Files
.
newBufferedWriter
(
path
))
{
writer
.
append
(
str
);
...
...
@@ -175,6 +178,12 @@ public class Compiler extends AbstractCompiler {
optionLogWrites
=
addOption
(
new
BooleanOption
(
"logWrites"
,
"Enable logging for every write."
)
.
defaultValue
(
false
));
optionLogIncremental
=
addOption
(
new
BooleanOption
(
"logIncremental"
,
"Enable logging for observer in incremental dependency tracking."
)
.
defaultValue
(
false
));
optionExperimentalJastAdd329
=
addOption
(
new
BooleanOption
(
"experimental-jastadd-329"
,
"Use trace events INC_FLUSH_START and INC_FLUSH_END (JastAdd issue #329)."
)
.
defaultValue
(
false
));
}
private
RagConnect
parseProgram
(
Collection
<
String
>
files
)
throws
CompilerException
{
...
...
@@ -195,14 +204,13 @@ public class Compiler extends AbstractCompiler {
case
"ast"
:
case
"relast"
:
// processGrammar
parseGrammar
(
program
,
filename
);
p
rogram
.
addGrammarFile
(
p
arseGrammar
(
filename
)
)
;
atLeastOneGrammar
=
true
;
break
;
case
"connect"
:
case
"ragconnect"
:
// process ragConnect
RagConnect
parsedRagConnect
=
parseRagConnect
(
program
,
filename
);
mergeRagConnectDefinitions
(
ragConnect
,
parsedRagConnect
);
ragConnect
.
addConnectSpecificationFile
(
parseConnectSpec
(
filename
));
atLeastOneRagConnect
=
true
;
break
;
default
:
...
...
@@ -210,10 +218,10 @@ public class Compiler extends AbstractCompiler {
}
}
if
(!
atLeastOneGrammar
)
{
System
.
err
.
println
(
"No grammar file specified! (*.ast, *.relast)"
);
LOGGER
.
severe
(()
->
"No grammar file specified! (*.ast, *.relast)"
);
}
if
(!
atLeastOneRagConnect
)
{
System
.
err
.
println
(
"No ragconnect file specified! (*.connect, *.ragconnect)"
);
LOGGER
.
severe
(()
->
"No ragconnect file specified! (*.connect, *.ragconnect)"
);
}
if
(!
atLeastOneGrammar
&&
!
atLeastOneRagConnect
)
{
System
.
exit
(
1
);
...
...
@@ -226,39 +234,40 @@ public class Compiler extends AbstractCompiler {
ragConnect
.
additionalRelations
().
forEach
(
ragConnectGrammarPart:
:
addDeclaration
);
ASTNode
.
loggingEnabledForReads
=
optionLogReads
.
value
();
ASTNode
.
loggingEnabledForWrites
=
optionLogWrites
.
value
();
ASTNode
.
loggingEnabledForIncremental
=
optionLogIncremental
.
value
();
ASTNode
.
experimentalJastAdd329
=
optionExperimentalJastAdd329
.
value
();
// reuse "--incremental" option of JastAdd
ASTNode
.
incrementalOptionActive
=
getConfiguration
().
incremental
()
&&
getConfiguration
().
traceFlush
();
printMessage
(
"ASTNode.incrementalOptionActive = "
+
ASTNode
.
incrementalOptionActive
);
LOGGER
.
fine
(()
->
"ASTNode.incrementalOptionActive = "
+
ASTNode
.
incrementalOptionActive
);
ASTNode
.
usesMqtt
=
optionProtocols
.
hasValue
(
OPTION_PROTOCOL_MQTT
);
ASTNode
.
usesRest
=
optionProtocols
.
hasValue
(
OPTION_PROTOCOL_REST
);
return
ragConnect
;
}
private
void
parseGrammar
(
Program
program
,
String
filename
)
throws
CompilerException
{
private
GrammarFile
parseGrammar
(
String
filename
)
throws
CompilerException
{
try
(
BufferedReader
reader
=
Files
.
newBufferedReader
(
Paths
.
get
(
filename
)))
{
RagConnectScanner
scanner
=
new
RagConnectScanner
(
reader
);
RagConnectParser
parser
=
new
RagConnectParser
();
GrammarFile
grammarFile
=
(
GrammarFile
)
parser
.
parse
(
scanner
);
if
(
optionVerbose
.
value
())
{
grammarFile
.
dumpTree
(
System
.
out
);
LOGGER
.
fine
(
grammarFile
:
:
dumpTree
);
}
program
.
addGrammarFile
(
grammarFile
);
grammarFile
.
setFileName
(
toBaseName
(
filename
));
return
grammarFile
;
}
catch
(
IOException
|
Parser
.
Exception
e
)
{
throw
new
CompilerException
(
"Could not parse grammar file "
+
filename
,
e
);
}
}
private
Rag
Connect
parse
Rag
Connect
(
Program
program
,
String
filename
)
throws
CompilerException
{
private
Connect
SpecificationFile
parseConnect
Spec
(
String
filename
)
throws
CompilerException
{
try
(
BufferedReader
reader
=
Files
.
newBufferedReader
(
Paths
.
get
(
filename
)))
{
RagConnectScanner
scanner
=
new
RagConnectScanner
(
reader
);
RagConnectParser
parser
=
new
RagConnectParser
();
RagConnect
ragConnect
=
(
RagConnect
)
parser
.
parse
(
scanner
,
RagConnectParser
.
AltGoals
.
ragconnect
);
ragConnect
.
setProgram
(
program
);
ragConnect
.
setFileName
(
toBaseName
(
filename
));
return
ragConnect
;
ConnectSpecificationFile
specificationFile
=
(
ConnectSpecificationFile
)
parser
.
parse
(
scanner
,
RagConnectParser
.
AltGoals
.
connect_specification_file
);
specificationFile
.
setFileName
(
toBaseName
(
filename
));
return
specificationFile
;
}
catch
(
IOException
|
Parser
.
Exception
e
)
{
throw
new
CompilerException
(
"Could not parse connect file "
+
filename
,
e
);
}
...
...
@@ -273,13 +282,6 @@ public class Compiler extends AbstractCompiler {
return
new
File
(
filename
).
getName
();
}
private
void
mergeRagConnectDefinitions
(
RagConnect
ragConnect
,
RagConnect
ragConnectToIntegrate
)
{
ragConnectToIntegrate
.
getEndpointDefinitionList
().
forEach
(
ragConnect:
:
addEndpointDefinition
);
ragConnectToIntegrate
.
getMappingDefinitionList
().
forEach
(
ragConnect:
:
addMappingDefinition
);
ragConnectToIntegrate
.
getDependencyDefinitionList
().
forEach
(
ragConnect:
:
addDependencyDefinition
);
ragConnect
.
setFileName
(
ragConnect
.
getFileName
().
isEmpty
()
?
ragConnectToIntegrate
.
getFileName
()
:
ragConnect
.
getFileName
()
+
" + "
+
ragConnectToIntegrate
.
getFileName
());
}
// protected void printUsage() {
// System.out.println("Usage: java -jar ragconnect.jar [--option1] [--option2=value] ... <filename1> <filename2> ... ");
// System.out.println("Options:");
...
...
ragconnect.base/src/main/java/org/jastadd/ragconnect/compiler/SimpleMain.java
deleted
100644 → 0
View file @
1f7396a9
package
org.jastadd.ragconnect.compiler
;
import
org.jastadd.ragconnect.ast.Document
;
import
org.jastadd.ragconnect.ast.ListElement
;
import
org.jastadd.ragconnect.ast.MappingElement
;
/**
* Testing Ros2Rag without parser.
*
* @author rschoene - Initial contribution
*/
public
class
SimpleMain
{
private
static
void
printManualYAML
()
{
Document
doc
=
new
Document
();
MappingElement
root
=
new
MappingElement
();
MappingElement
firstLevel
=
new
MappingElement
();
firstLevel
.
put
(
"server"
,
"tcp://localhost:1883"
);
firstLevel
.
put
(
"robot_speed_factor"
,
".7"
);
MappingElement
theTopics
=
new
MappingElement
();
theTopics
.
put
(
"robotConfig"
,
"robotconfig"
);
theTopics
.
put
(
"trajectory"
,
"trajectory"
);
theTopics
.
put
(
"nextStep"
,
"ros2rag/nextStep"
);
firstLevel
.
put
(
"topics"
,
theTopics
);
firstLevel
.
put
(
"zone_size"
,
"0.5"
);
ListElement
theZones
=
new
ListElement
();
theZones
.
add
(
"1 1"
);
theZones
.
add
(
"0 1"
);
theZones
.
add
(
"-1 1"
);
firstLevel
.
put
(
"zones"
,
theZones
);
MappingElement
pandaParts
=
new
MappingElement
();
MappingElement
thePanda
=
new
MappingElement
();
thePanda
.
put
(
"Link0"
,
"panda_link0"
);
thePanda
.
put
(
"Link1"
,
"panda_link1"
);
thePanda
.
put
(
"Link2"
,
"panda_link2"
);
thePanda
.
put
(
"Link3"
,
"panda_link3"
);
thePanda
.
put
(
"Link4"
,
"panda_link4"
);
thePanda
.
put
(
"Link5"
,
"panda_link5"
);
thePanda
.
put
(
"Link6"
,
"panda_link6"
);
thePanda
.
put
(
"RightFinger"
,
"panda_rightfinger"
);
thePanda
.
put
(
"LeftFinger"
,
"panda_leftfinger"
);
pandaParts
.
put
(
"panda"
,
thePanda
);
firstLevel
.
put
(
"parts"
,
pandaParts
);