Commit 05370462 authored by Nina Pichler's avatar Nina Pichler
Browse files

fixed some bugs in grammar (need to update java source files to use now new generated AST)

parent f7d019c5
......@@ -22,7 +22,7 @@ package de.monticore.lang.embeddedmontiarc;
/**
* Grammar for EmbeddedMontiArc.
*
* @author Sascha Schneiders, Sining Wang, Yu Qiao
* @author Michael von Wenckstern, Nina Pichler, Sascha Schneiders, Sining Wang, Yu Qiao
*/
grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticore.lang.monticar.Ranges, de.monticore.lang.monticar.MCExpressions, de.monticore.lang.monticar.Types2 {
......@@ -69,15 +69,7 @@ Stereotype =
* @attribute body contains the architectural elements
* inherited by this component
*/
symbol scope Component implements Element =
Stereotype?
"component" Name
head:ComponentHead
(instanceName:Name actualTypeArgument:TypeArguments?)?
body:ComponentBody;
/**
/**
* A components head is used to define generic type
* parameters that may be used as port types in the
* component, to define configuration parameters that may
......@@ -94,10 +86,16 @@ Stereotype =
* @attribute superComponent the type of the super
* component
*/
ComponentHead =
((genericTypeParameters:TypeParameters)|())?
symbol scope Component implements Element =
Stereotype?
"component" Name
genericTypeParameters:TypeParameters // TypeParameters is optional itself
("(" (Parameter || ",")+ ")")?
("extends" superComponent:ReferenceType)?;
("implements" superComponent:ReferenceType)?
body:ComponentBody;
......
......@@ -23,7 +23,10 @@ package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast;
//import de.monticore.common.common._ast.ASTStereotype;
//import de.monticore.types.types._ast.ASTTypeArguments;
import de.monticore.lang.monticar.common2._ast.ASTParameter;
import de.monticore.lang.monticar.types2._ast.ASTReferenceType;
import de.monticore.lang.monticar.types2._ast.ASTTypeArguments;
import de.monticore.lang.monticar.types2._ast.ASTTypeParameters;
import java.util.ArrayList;
import java.util.List;
......@@ -43,13 +46,20 @@ public class ASTComponent extends ASTComponentTOP {
}
protected ASTComponent(
ASTStereotype stereotype,
String name,
ASTComponentHead head,
String instanceName,
ASTTypeArguments actualTypeArgument,
ASTComponentBody body) {
super(stereotype, name, head, instanceName, actualTypeArgument, body);
ASTStereotype stereotype
,
String name
,
ASTTypeParameters genericTypeParameters
,
List<ASTParameter> parameters
,
ASTReferenceType superComponent
,
ASTComponentBody body
) {
super(stereotype, name, genericTypeParameters, parameters, superComponent, body);
}
// do not use symbol table, since symbol table must not be created
......
......@@ -21,7 +21,6 @@
package de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTComponent;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTComponentHead;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTConnector;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTEMACompilationUnit;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTMontiArcAutoConnect;
......@@ -798,9 +797,7 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
}
private void handleResolutionDeclaration(ComponentSymbol typeSymbol,
Optional<ASTTypeParameters> optionalTypeParameters, Scope currentScope, ASTComponent node) {
if (optionalTypeParameters.isPresent()) {
ASTTypeParameters astTypeParameters = optionalTypeParameters.get();
ASTTypeParameters astTypeParameters, Scope currentScope, ASTComponent node) {
for (ASTTypeVariableDeclaration astTypeParameter : astTypeParameters
.getTypeVariableDeclarations()) {
if (astTypeParameter.resolutionDeclarationIsPresent() && astTypeParameter.getResolutionDeclaration().get() instanceof ASTTypeNameResolutionDeclaration) {
......@@ -817,7 +814,6 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
addToScopeAndLinkWithNode(resDeclSymRef, astTypeParameter);
}
}
}
}
......@@ -839,11 +835,11 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
//Handle ResolutionDeclaration of stuff like <N1 n=5>
handleResolutionDeclaration(component, node.getHead().getGenericTypeParameters(), currentScope().get(), node);
handleResolutionDeclaration(component, node.getGenericTypeParameters(), currentScope().get(), node);
Log.debug(component.toString(), "ComponentPreGeneric");
// generic type parameters
EMAJavaHelper.addTypeParametersToType(component, node.getHead().getGenericTypeParameters(),
EMAJavaHelper.addTypeParametersToType(component, node.getGenericTypeParameters(),
currentScope().get());
Log.debug(component.toString(), "ComponentPostGeneric");
......@@ -904,11 +900,10 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
autoConnectionTrafo.transform(node, componentStack.peek());
}
private void setParametersOfComponent(final ComponentSymbol componentSymbol,
final ASTComponentHead astMethod) {
private void setParametersOfComponent(final ComponentSymbol componentSymbol) {
Log.debug(componentSymbol.toString(), "ComponentPreParam");
Log.debug(astMethod.toString(), "ASTComponentHead");
for (ASTParameter astParameter : astMethod.getParameters()) {
ASTComponent cmp = (ASTComponent)componentSymbol.getAstNode().get();
for (ASTParameter astParameter : cmp.getParameters()) {
final String paramName = astParameter.getName();
Log.debug(astParameter.toString(), "ASTParam");
int dimension = TypesHelper.getArrayDimensionIfArrayOrZero(astParameter.getType());
......@@ -929,7 +924,7 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
}
private boolean needsInstanceCreation(ASTComponent node, ComponentSymbol symbol) {
boolean instanceNameGiven = node.getInstanceName().isPresent();
boolean instanceNameGiven = false;// node.getInstanceName().isPresent();
boolean autoCreationPossible = symbol.getFormalTypeParameters().size() == 0;
return autoInstantiate && (instanceNameGiven || autoCreationPossible);
......
package a;
component SuperCompExtension extends SuperComp{
component SuperCompExtension implements SuperComp{
}
\ No newline at end of file
package a;
component SuperCompGenericExtension extends SuperCompGeneric<(0:1:100)>{
component SuperCompGenericExtension implements SuperCompGeneric<(0:1:100)>{
}
\ No newline at end of file
package a;
component SuperCompGenericGenericExtension<N1 n = 1> extends SuperCompGenericGeneric<n>{
component SuperCompGenericGenericExtension<N1 n = 1> implements SuperCompGenericGeneric<n>{
}
\ No newline at end of file
package a;
component SuperCompGenericGenericExtensionInstance extends SuperCompGenericGenericExtension<5>{
component SuperCompGenericGenericExtensionInstance implements SuperCompGenericGenericExtension<5>{
}
\ No newline at end of file
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