Commit cb7386a2 authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Added adaptable keyword to incoming ports to create config ports

parent a6bd43db
......@@ -124,7 +124,7 @@ grammar EmbeddedMontiArc extends de.monticore.lang.monticar.Common2, de.monticor
* declaration later on
*/
Port =
NEWLINETOKEN*(incoming:["in"] | outgoing:["out"])
NEWLINETOKEN*(AdaptableKeyword? incoming:["in"] | outgoing:["out"])
Type (Name? | Name ( "[" UnitNumberResolution "]" )?) NEWLINETOKEN*;
......
......@@ -292,7 +292,7 @@ public class EmbeddedMontiArcSymbolTableCreator extends EmbeddedMontiArcSymbolTa
public void createPort(ASTPort node, String name, boolean isIncoming,
MCTypeReference<? extends MCTypeSymbol> typeRef, PortArraySymbol pas) {
PortSymbol ps;
if(node instanceof ASTConfigPort) {
if(node instanceof ASTConfigPort || node.adaptableKeywordIsPresent()) {
ps = new ConfigPortSymbol(name);
}else {
ps = new PortSymbol(name);
......
......@@ -209,6 +209,22 @@ public class ExpandedComponentInstanceTest extends AbstractSymtabTest {
assertNull(subInst1.getIncomingPort("param2").orElse(null));
}
@Test
public void testConfigPort(){
Scope symtab = createSymTab("src/test/resources");
ExpandedComponentInstanceSymbol comp = symtab.<ExpandedComponentInstanceSymbol>resolve("testing.configPort",ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(comp);
PortSymbol configPort = comp.getIncomingPort("in1").orElse(null);
assertNotNull(configPort);
assertTrue(configPort.isConfig());
PortSymbol nonConfigPort = comp.getIncomingPort("in2").orElse(null);
assertNotNull(nonConfigPort);
assertFalse(nonConfigPort.isConfig());
}
@Test
public void testExtensionMechanism1() {
Scope symTab = createSymTab("src/test/resources");
......
......@@ -52,7 +52,7 @@ import org.junit.Test;
public class ParserTest {
public static final boolean ENABLE_FAIL_QUICK = false;
private static List<String> expectedParseErrorModels = Arrays.asList(
"")
"src/test/resources/testing/ConfigPortInvalid.ema")
.stream().map(s -> Paths.get(s).toString())
.collect(Collectors.toList());
......
package testing;
component ConfigPort{
port adaptable in Q in1;
port in Q in2;
}
\ No newline at end of file
package testing;
component ConfigPortInvalid{
//only incoming ports can be config
port adaptable out Q in1;
}
\ 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