Commit ec21b927 authored by Christoph Richter's avatar Christoph Richter
Browse files

EmbeddedMontiArc.mc4: Removed NEWLINE token

parent f4867c69
......@@ -31,9 +31,9 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2 {
* @attribute importStatements List of imported elements
* @attribute Component the root component of the component
*/
EMACompilationUnit =NEWLINETOKEN*
("package" package:(Name& || ".")+ ";")? NEWLINETOKEN*
(ImportStatement NEWLINETOKEN*)*
EMACompilationUnit =
("package" package:(Name& || ".")+ ";")?
(ImportStatement )*
Component;
......@@ -82,10 +82,10 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2 {
*/
symbol scope Component implements Element =
NEWLINETOKEN* "component" Name
genericTypeParameters:TypeParameters // TypeParameters is optional itself
( NEWLINETOKEN* "(" NEWLINETOKEN* (Parameter || ",")+ NEWLINETOKEN*")" NEWLINETOKEN*)? NEWLINETOKEN*
("implements" superComponent:ReferenceType)? NEWLINETOKEN*
"component" Name
genericTypeParameters:TypeParameters?
( "(" (Parameter || ",")+ ")" )?
("implements" superComponent:ReferenceType)?
body:ComponentBody;
......@@ -96,9 +96,9 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2 {
* @attribute elements list of architectural elements
*/
ComponentBody =
("{" NEWLINETOKEN*
("{"
Element*
"}" NEWLINETOKEN*);
"}" );
/**
* An Interface defines an interface of a component
......@@ -107,9 +107,9 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2 {
* this interface
*/
Interface implements Element =
NEWLINETOKEN* ("port"|"ports")
ports:(Port || ",")+ ";" NEWLINETOKEN*;
("port"|"ports")
ports:(Port || ",")+ ";" ;
/**a
* An incoming port is used to receive messages, an
* outgoing port is used to send messages of a specific
......@@ -124,8 +124,8 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2 {
* declaration later on
*/
Port =
NEWLINETOKEN*(AdaptableKeyword? incoming:["in"] | outgoing:["out"])
Type (Name? | Name ( "[" UnitNumberResolution "]" )?) NEWLINETOKEN*;
AdaptableKeyword? (incoming:["in"] | outgoing:["out"])
Type (Name? | Name ( "[" UnitNumberResolution "]" )?) ;
/**
......@@ -140,10 +140,10 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2 {
* created
*/
SubComponent implements Element =
NEWLINETOKEN* "instance"
"instance"
type:ReferenceType
("(" arguments:(Expression || ",")+ ")" )?
instances:(SubComponentInstance || ",")* ";" NEWLINETOKEN*;
instances:(SubComponentInstance || ",")* ";" ;
/**
......@@ -160,7 +160,7 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2 {
// TODO better/more intuitive name? e.g. "refConnector" (not really good...)
SubComponentInstance =
Name
("[" UnitNumberResolution "]")? NEWLINETOKEN*;
("[" UnitNumberResolution "]")? ;
/**
* A connector connects one source port with one or many
......@@ -172,10 +172,10 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2 {
* instance names
*/
Connector implements Element=
NEWLINETOKEN* "connect" (source:QualifiedNameWithArray | (boolLiteral:BooleanLiteral) | (stringLiteral:StringLiteral)| UnitNumberResolution) "->"
targets:ConnectorTargets ";" NEWLINETOKEN*;
"connect" (source:QualifiedNameWithArray | (boolLiteral:BooleanLiteral) | (stringLiteral:StringLiteral)| UnitNumberResolution) "->"
targets:ConnectorTargets ";" ;
ConnectorTargets = (QualifiedNameWithArray (",")? NEWLINETOKEN* )+;
ConnectorTargets = (QualifiedNameWithArray (",")? )+;
/* ======================================================*/
/* ============ From OLD MARC Grammar ==================*/
......@@ -198,8 +198,8 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2 {
* @attribute off do not use autoconnection (default)
*/
MontiArcAutoConnect implements MontiArcConfig =
NEWLINETOKEN* "autoconnect"
(["type"] | ["port"] | ["off"]) ";" NEWLINETOKEN*;
"autoconnect"
(["type"] | ["port"] | ["off"]) ";";
/**
* AutoInstantiate is used to automatically instantiate inner components.
......@@ -209,12 +209,6 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2 {
* @attribute off do not use autoinstantiate (default)
*/
MontiArcAutoInstantiate implements MontiArcConfig =
NEWLINETOKEN* "autoinstantiate"
(["on"] | ["off"]) ";" NEWLINETOKEN*;
token NEWLINETOKEN =
('\r' '\n' |
'\r' |
'\n' ):
;
"autoinstantiate"
(["on"] | ["off"]) ";";
}
......@@ -29,9 +29,6 @@ import de.se_rwth.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
//import de.monticore.types.types._ast.ASTTypeParameters;
//import de.monticore.types.types._ast.ASTTypeVariableDeclaration;
/**
* @author (last commit) Crispin Kirchner
*/
......@@ -42,20 +39,18 @@ public class TypeParameterNamesUnique implements EmbeddedMontiArcASTComponentCoC
*/
@Override
public void check(ASTComponent node) {
ASTTypeParameters typeParameters = node.getGenericTypeParameters();
if (typeParameters == null) {
return;
}
List<String> typeParameterNames = new ArrayList<>();
for (ASTTypeVariableDeclaration typeParameter : typeParameters.getTypeVariableDeclarationList()) {
if (typeParameterNames.contains(typeParameter.getName())) {
Log.error(String.format(
"0x35F1A The formal type parameter name \"%s\" is not unique",
typeParameter.getName()), typeParameter.get_SourcePositionStart());
} else {
//typeParameterNames.add(typeParameter.getNamingResolution().get().getName());
if (node.getGenericTypeParametersOpt().isPresent()) {
ASTTypeParameters typeParameters = node.getGenericTypeParametersOpt().get();
List<String> typeParameterNames = new ArrayList<>();
for (ASTTypeVariableDeclaration typeParameter : typeParameters.getTypeVariableDeclarationList()) {
if (typeParameterNames.contains(typeParameter.getName())) {
Log.error(String.format(
"0x35F1A The formal type parameter name \"%s\" is not unique",
typeParameter.getName()), typeParameter.get_SourcePositionStart());
} else {
//typeParameterNames.add(typeParameter.getNamingResolution().get().getName());
}
}
}
}
......
......@@ -35,40 +35,15 @@ 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
* @param name
* @param genericTypeParameters
* @param parameters
* @param superComponent
* @param nEWLINETOKENs
* @param body
*/
public ASTComponent(String name, ASTTypeParameters genericTypeParameters, List<ASTParameter> parameters, Optional<ASTReferenceType> superComponent, List<String> nEWLINETOKENs, ASTComponentBody body) {
super();
}
protected ASTComponent(
String name
,
ASTTypeParameters genericTypeParameters
,
List<ASTParameter> parameters
,
ASTReferenceType superComponent
,
java.util.List<String> nEWLINETOKENs,
ASTComponentBody body
) {
super(name, genericTypeParameters, parameters, java.util.Optional.ofNullable(superComponent), nEWLINETOKENs, body);
}
public ASTComponent() {
super();
}
public ASTComponent(String name, Optional<ASTTypeParameters> genericTypeParameters, List<ASTParameter> parameters, Optional<ASTReferenceType> superComponent, ASTComponentBody body) {
super(name, genericTypeParameters, parameters, superComponent, body);
}
// do not use symbol table, since symbol table must not be created
public List<ASTPort> getPortsList() {
List<ASTPort> ret = new ArrayList<>();
......
......@@ -20,6 +20,10 @@
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast;
import de.monticore.lang.monticar.common2._ast.ASTQualifiedNameWithArray;
import java.util.List;
/**
* @author Sascha Schneiders
*/
......@@ -28,13 +32,7 @@ public class ASTConnectorTargets extends ASTConnectorTargetsTOP {
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);
public ASTConnectorTargets(List<ASTQualifiedNameWithArray> qualifiedNameWithArrays) {
super(qualifiedNameWithArrays);
}
}
......@@ -283,13 +283,17 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
component.setPackageName(componentPackageName);
// Handle ResolutionDeclaration of stuff like <N1 n=5>
handleResolutionDeclaration(component, node.getGenericTypeParameters(), currentScope().get(),
node, this);
if (node.getGenericTypeParametersOpt().isPresent()) {
handleResolutionDeclaration(component, node.getGenericTypeParametersOpt().get(), currentScope().get(),
node, this);
}
Log.debug(component.toString(), "ComponentPreGeneric");
// generic type parameters
EMAJavaHelper.addTypeParametersToType(component, node.getGenericTypeParameters(),
currentScope().get());
if (node.getGenericTypeParametersOpt().isPresent()) {
EMAJavaHelper.addTypeParametersToType(component, node.getGenericTypeParametersOpt().get(),
currentScope().get());
}
Log.debug(component.toString(), "ComponentPostGeneric");
// parameters
......
......@@ -144,7 +144,7 @@ public class AutoConnection {
targets.add(target);
astConnector.setSource(source);
astConnector.setTargets(new ASTConnectorTargets(targets, new ArrayList<String>()));
astConnector.setTargets(new ASTConnectorTargets(targets));
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