Commit a334b1cb authored by Sascha Niklas Schneiders's avatar Sascha Niklas Schneiders
Browse files

updated to new version, new lines are now used to resolve ambiguities

parent 2ce9aa21
......@@ -30,7 +30,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc</artifactId>
<version>0.0.10-SNAPSHOT</version>
<version>0.0.11-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......
......@@ -31,9 +31,9 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
* @attribute importStatements List of imported elements
* @attribute Component the root component of the component
*/
EMACompilationUnit =
("package" package:(Name& || ".")+ ";")?
(ImportStatement)*
EMACompilationUnit =NEWLINETOKEN*
("package" package:(Name& || ".")+ ";")? NEWLINETOKEN*
(ImportStatement NEWLINETOKEN*)*
Component;
......@@ -82,10 +82,10 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
*/
symbol scope Component implements Element =
"component" Name
NEWLINETOKEN* "component" Name
genericTypeParameters:TypeParameters // TypeParameters is optional itself
("(" (Parameter || ",")+ ")")?
("implements" superComponent:ReferenceType)?
("implements" superComponent:ReferenceType)? NEWLINETOKEN*
body:ComponentBody;
......@@ -96,9 +96,9 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
* @attribute elements list of architectural elements
*/
ComponentBody =
("{"
("{" NEWLINETOKEN*
Element*
"}");
"}" NEWLINETOKEN*);
/**
* An Interface defines an interface of a component
......@@ -107,8 +107,8 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
* this interface
*/
Interface implements Element =
("port"|"ports")
ports:(Port || ",")+ ";";
NEWLINETOKEN* ("port"|"ports")
ports:(Port || ",")+ ";" NEWLINETOKEN*;
/**a
* An incoming port is used to receive messages, an
......@@ -124,8 +124,8 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
* declaration later on
*/
Port =
(incoming:["in"] | outgoing:["out"])
Type (Name? | Name ( "[" UnitNumberResolution "]" )?);
NEWLINETOKEN*(incoming:["in"] | outgoing:["out"])
Type (Name? | Name ( "[" UnitNumberResolution "]" )?) NEWLINETOKEN*;
/**
......@@ -140,10 +140,10 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
* created
*/
SubComponent implements Element =
"instance"
NEWLINETOKEN* "instance"
type:ReferenceType
("(" arguments:(Expression || ",")+ ")" )?
instances:(SubComponentInstance || ",")* ";";
instances:(SubComponentInstance || ",")* ";" NEWLINETOKEN*;
/**
......@@ -160,7 +160,7 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
// TODO better/more intuitive name? e.g. "refConnector" (not really good...)
SubComponentInstance =
Name
("[" UnitNumberResolution "]")?;
("[" UnitNumberResolution "]")? NEWLINETOKEN*;
/**
* A connector connects one source port with one or many
......@@ -172,9 +172,10 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
* instance names
*/
Connector implements Element=
"connect" (source:QualifiedNameWithArray | (boolLiteral:BooleanLiteral) | (stringLiteral:StringLiteral)| UnitNumberResolution) "->"
targets:(QualifiedNameWithArray || ",")+ ";";
NEWLINETOKEN* "connect" (source:QualifiedNameWithArray | (boolLiteral:BooleanLiteral) | (stringLiteral:StringLiteral)| UnitNumberResolution) "->"
targets:ConnectorTargets ";" NEWLINETOKEN*;
ConnectorTargets = (QualifiedNameWithArray (",")? NEWLINETOKEN* )+;
/* ======================================================*/
/* ============ From OLD MARC Grammar ==================*/
......@@ -197,8 +198,8 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
* @attribute off do not use autoconnection (default)
*/
MontiArcAutoConnect implements MontiArcConfig =
"autoconnect"
(["type"] | ["port"] | ["off"]) ";";
NEWLINETOKEN* "autoconnect"
(["type"] | ["port"] | ["off"]) ";" NEWLINETOKEN*;
/**
* AutoInstantiate is used to automatically instantiate inner components.
......@@ -208,8 +209,8 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
* @attribute off do not use autoinstantiate (default)
*/
MontiArcAutoInstantiate implements MontiArcConfig =
"autoinstantiate"
(["on"] | ["off"]) ";";
NEWLINETOKEN* "autoinstantiate"
(["on"] | ["off"]) ";" NEWLINETOKEN*;
......@@ -218,4 +219,9 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
Ranges implements PrintType,TypeArgument=
"[" Range+ "]";
token NEWLINETOKEN =
('\r' '\n' |
'\r' |
'\n' ):
;
}
......@@ -68,7 +68,7 @@ public class ConnectorEndPointCorrectlyQualified
Log.error("Error Connector has no valid source or constant " + node.toString());
}
for (ASTQualifiedNameWithArray name : node.getTargets()) {
for (ASTQualifiedNameWithArray name : node.getTargets().getQualifiedNameWithArrays()) {
checkEndPointMaximallyTwiceQualified(name);
}
}
......
......@@ -73,7 +73,7 @@ public class InPortUniqueSender implements EmbeddedMontiArcASTComponentCoCo {
private void checkConnectors() {
for (ASTConnector connector : node.getConnectors()) {
for (ASTQualifiedNameWithArray target : connector.getTargets()) {
for (ASTQualifiedNameWithArray target : connector.getTargets().getQualifiedNameWithArrays()) {
checkTarget(target);
}
}
......
......@@ -35,7 +35,7 @@ public class SourceTargetNumberMatch implements EmbeddedMontiArcASTConnectorCoCo
sourceNum = getSourceNum(node);
for (ASTQualifiedNameWithArray target : node.getTargets()) {
for (ASTQualifiedNameWithArray target : node.getTargets().getQualifiedNameWithArrays()) {
targetNum = getTargetNum(target);
......
......@@ -34,54 +34,56 @@ import java.util.stream.Collectors;
* @author Robert Heim, Michael von Wenckstern
*/
public class ASTComponent extends ASTComponentTOP {
/**
* Constructor for de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTComponent
*/
public ASTComponent() {
super();
}
/**
* Constructor for de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTComponent
*/
public ASTComponent() {
super();
}
protected ASTComponent(
String name
,
ASTTypeParameters genericTypeParameters
,
List<ASTParameter> parameters
,
ASTReferenceType superComponent
,
java.util.List<String> nEWLINETOKENs,
protected ASTComponent(
String name
,
ASTTypeParameters genericTypeParameters
,
List<ASTParameter> parameters
,
ASTReferenceType superComponent
,
ASTComponentBody body
ASTComponentBody body
) {
super(name, genericTypeParameters, parameters, superComponent, body);
}
) {
super(name, genericTypeParameters, parameters, superComponent, nEWLINETOKENs, body);
}
// do not use symbol table, since symbol table must not be created
public List<ASTPort> getPorts() {
List<ASTPort> ret = new ArrayList<>();
for (ASTElement element : this.getBody().getElements()) {
if (element instanceof ASTInterface) {
ret.addAll(((ASTInterface) element).getPorts());
}
// do not use symbol table, since symbol table must not be created
public List<ASTPort> getPorts() {
List<ASTPort> ret = new ArrayList<>();
for (ASTElement element : this.getBody().getElements()) {
if (element instanceof ASTInterface) {
ret.addAll(((ASTInterface) element).getPorts());
}
}
return ret;
}
return ret;
}
// do not use symbol table, since symbol table must not be created
public List<ASTConnector> getConnectors() {
return this.getBody().getElements().stream().filter(a -> a instanceof ASTConnector).
map(a -> (ASTConnector) a).collect(Collectors.toList());
}
// do not use symbol table, since symbol table must not be created
public List<ASTConnector> getConnectors() {
return this.getBody().getElements().stream().filter(a -> a instanceof ASTConnector).
map(a -> (ASTConnector) a).collect(Collectors.toList());
}
// do not use symbol table, since symbol table must not be created
public List<ASTSubComponent> getSubComponents() {
return this.getBody().getElements().stream().filter(a -> a instanceof ASTSubComponent).
map(a -> (ASTSubComponent) a).collect(Collectors.toList());
}
// do not use symbol table, since symbol table must not be created
public List<ASTSubComponent> getSubComponents() {
return this.getBody().getElements().stream().filter(a -> a instanceof ASTSubComponent).
map(a -> (ASTSubComponent) a).collect(Collectors.toList());
}
// do not use symbol table, since symbol table must not be created
public List<ASTComponent> getInnerComponents() {
return this.getBody().getElements().stream().filter(a -> a instanceof ASTComponent).
map(a -> (ASTComponent) a).collect(Collectors.toList());
}
// do not use symbol table, since symbol table must not be created
public List<ASTComponent> getInnerComponents() {
return this.getBody().getElements().stream().filter(a -> a instanceof ASTComponent).
map(a -> (ASTComponent) a).collect(Collectors.toList());
}
}
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast;
/**
* @author Sascha Schneiders
*/
public class ASTConnectorTargets extends ASTConnectorTargetsTOP {
public ASTConnectorTargets() {
super();
}
/* generated by template ast.Constructor*/
public ASTConnectorTargets(
java.util.List<de.monticore.lang.monticar.common2._ast.ASTQualifiedNameWithArray> qualifiedNameWithArrays
, java.util.List<String> nEWLINETOKENs
) {
super(qualifiedNameWithArrays, nEWLINETOKENs);
}
}
......@@ -531,7 +531,7 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
Log.info("" + sourceNames.size(), "SourcePorts");
int counter = 0, targetnum = 0;
for (ASTQualifiedNameWithArray target : node.getTargets()) {
for (ASTQualifiedNameWithArray target : node.getTargets().getQualifiedNameWithArrays()) {
counter = 0;
targetnum = 0;
for (String sourceName : sourceNames) {
......@@ -562,7 +562,7 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
int counter = 0, targetnum = 0;
ConstantPortSymbol constantPortSymbol = ConstantPortSymbol.createConstantPortSymbol(node, this);
addToScope(constantPortSymbol);
for (ASTQualifiedNameWithArray target : node.getTargets()) {
for (ASTQualifiedNameWithArray target : node.getTargets().getQualifiedNameWithArrays()) {
counter = 0;
targetnum = 0;
List<String> targetNames = getPortName(target, 0);
......
......@@ -136,7 +136,7 @@ public class AutoConnection {
targets.add(target);
astConnector.setSource(source);
astConnector.setTargets(targets);
astConnector.setTargets(new ASTConnectorTargets(targets, new ArrayList<String>()));
Optional<ASTMontiArcAutoConnect> auto = resolveAutoconnect(node);
if (auto.isPresent()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment