Skip to content
Snippets Groups Projects
Commit 1f707942 authored by René Schöne's avatar René Schöne
Browse files

working on context-free connect

- add error messages and tests for them
- also marked (commented out) tests in negative tests that are not currently handled
parent 8e85179e
No related branches found
No related tags found
1 merge request!22Resolve "Feature: Add context-free connect"
Pipeline #12144 passed
...@@ -27,10 +27,16 @@ aspect Errors { ...@@ -27,10 +27,16 @@ aspect Errors {
token().effectiveJavaTypeUse()) token().effectiveJavaTypeUse())
to RagConnect.errors(); to RagConnect.errors();
ContextFreeTypeEndpointTarget contributes error("Context-Free endpoint not allowed for root nodes!") ContextFreeTypeEndpointTarget contributes error("Context-Free endpoint not allowed for root node " +
getTypeDecl().getName() + "!")
when getTypeDecl().occurencesInProductionRules().isEmpty() when getTypeDecl().occurencesInProductionRules().isEmpty()
to RagConnect.errors(); to RagConnect.errors();
EndpointDefinition contributes error("Clash with implied, indexed endpoint definition of context-free endpoint in line " +
clashingContextFreeEndpointDefinition().getStartLine() + "!")
when !getSend() && clashingContextFreeEndpointDefinition() != null
to RagConnect.errors();
DependencyDefinition contributes error("Dependency definition already defined for " + getSource().containingTypeDecl().getName() + " with name " + getID()) DependencyDefinition contributes error("Dependency definition already defined for " + getSource().containingTypeDecl().getName() + " with name " + getID())
when isAlreadyDefined() when isAlreadyDefined()
to RagConnect.errors(); to RagConnect.errors();
...@@ -49,6 +55,18 @@ aspect ErrorHelpers { ...@@ -49,6 +55,18 @@ aspect ErrorHelpers {
} }
return false; return false;
} }
syn EndpointDefinition EndpointDefinition.clashingContextFreeEndpointDefinition() {
if (getSend() || !typeIsList() || getIndexBasedListAccess()) {
return null;
}
List<EndpointDefinition> contextFreeEndpointsWithSameType = lookupContextFreeTypeEndpointDefinitions(
getEndpointTarget().asTypeEndpointTarget().getType().getTypeDecl());
if (!contextFreeEndpointsWithSameType.isEmpty()) {
return contextFreeEndpointsWithSameType.get(0);
}
return null;
}
} }
aspect ErrorMessage { aspect ErrorMessage {
......
...@@ -3,6 +3,7 @@ aspect ParserRewrites { ...@@ -3,6 +3,7 @@ aspect ParserRewrites {
when (getChildName() != null && tryGloballyResolveTypeComponentByToken(combinedName()) != null) when (getChildName() != null && tryGloballyResolveTypeComponentByToken(combinedName()) != null)
to TypeEndpointTarget { to TypeEndpointTarget {
TypeEndpointTarget result = new TypeEndpointTarget(); TypeEndpointTarget result = new TypeEndpointTarget();
result.copyOtherValuesFrom(this);
result.setType(TypeComponent.createRef(this.combinedName())); result.setType(TypeComponent.createRef(this.combinedName()));
return result; return result;
} }
...@@ -10,6 +11,7 @@ aspect ParserRewrites { ...@@ -10,6 +11,7 @@ aspect ParserRewrites {
when (getChildName() != null && tryGloballyResolveTokenComponentByToken(combinedName()) != null) when (getChildName() != null && tryGloballyResolveTokenComponentByToken(combinedName()) != null)
to TokenEndpointTarget { to TokenEndpointTarget {
TokenEndpointTarget result = new TokenEndpointTarget(); TokenEndpointTarget result = new TokenEndpointTarget();
result.copyOtherValuesFrom(this);
result.setToken(TokenComponent.createRef(this.combinedName())); result.setToken(TokenComponent.createRef(this.combinedName()));
return result; return result;
} }
...@@ -17,6 +19,7 @@ aspect ParserRewrites { ...@@ -17,6 +19,7 @@ aspect ParserRewrites {
when (getChildName() == "") when (getChildName() == "")
to ContextFreeTypeEndpointTarget { to ContextFreeTypeEndpointTarget {
ContextFreeTypeEndpointTarget result = new ContextFreeTypeEndpointTarget(); ContextFreeTypeEndpointTarget result = new ContextFreeTypeEndpointTarget();
result.copyOtherValuesFrom(this);
result.setTypeDecl(TypeDecl.createRef(getTypeName())); result.setTypeDecl(TypeDecl.createRef(getTypeName()));
return result; return result;
} }
...@@ -24,6 +27,11 @@ aspect ParserRewrites { ...@@ -24,6 +27,11 @@ aspect ParserRewrites {
syn String UntypedEndpointTarget.combinedName() = getTypeName() + "." + getChildName(); syn String UntypedEndpointTarget.combinedName() = getTypeName() + "." + getChildName();
protected void EndpointTarget.copyOtherValuesFrom(EndpointTarget source) {
this.setStart(source.getStartLine(), source.getStartColumn());
this.setEnd(source.getEndLine(), source.getEndColumn());
}
eq UntypedEndpointTarget.senderName() = "<untyped.senderName>"; eq UntypedEndpointTarget.senderName() = "<untyped.senderName>";
eq UntypedEndpointTarget.getterMethodName() = "<untyped.getterMethodName>"; eq UntypedEndpointTarget.getterMethodName() = "<untyped.getterMethodName>";
eq UntypedEndpointTarget.parentTypeName() = "<untyped.parentTypeName>"; eq UntypedEndpointTarget.parentTypeName() = "<untyped.parentTypeName>";
......
receive A; receive A;
//// implied //"receive Root.A;" is implied
//receive Root.A;
receive Root.SingleA using PrependPrefix; receive Root.SingleA using PrependPrefix;
receive Root.OptA using AddSuffix; receive Root.OptA using AddSuffix;
//"receive Root.ListA;" would clash //"receive Root.ListA;" would clash as "receive indexed Root.ListA" is implied
PrependPrefix maps A a to A {: PrependPrefix maps A a to A {:
A result = new A(); A result = new A();
......
A ::= B C D ; A ::= B C D E* ;
// read definitions // read definitions
B ::= /<ErrorNTA:String>/ <ErrorTypeOfFirstMapping:String> <ErrorTypeOfLastMapping:String> <DoubledValue:int> <ErrorTypeMismatch:String> ; B ::= /<ErrorNTA:String>/ <ErrorTypeOfFirstMapping:String> <ErrorTypeOfLastMapping:String> <DoubledValue:int> <ErrorTypeMismatch:String> ;
// write definitions // write definitions
C ::= <ErrorNotNTA:String> /<ErrorTypeOfFirstMapping:String>/ /<ErrorTypeOfLastMapping1:String>/ /<ErrorTypeOfLastMapping2:List<String>>/ /<ErrorTypeMismatch:String>/ /<DoubledValue:int>/ ; C ::= /<ErrorTypeOfFirstMapping:String>/ /<ErrorTypeOfLastMapping1:String>/ /<ErrorTypeOfLastMapping2:List<String>>/ /<ErrorTypeMismatch:String>/ /<DoubledValue:int>/ ;
// dependency definitions // dependency definitions
D ::= <SourceNonExistingTarget> D ::= <SourceNonExistingTarget>
...@@ -13,3 +13,6 @@ D ::= <SourceNonExistingTarget> ...@@ -13,3 +13,6 @@ D ::= <SourceNonExistingTarget>
<SourceSameAsListNode> /<TargetSameAsListNode>/ <SourceSameAsListNode> /<TargetSameAsListNode>/
<SourceDoubledValue> /<TargetDoubledValue>/ <SourceDoubledValue> /<TargetDoubledValue>/
MyList:D* ; MyList:D* ;
// context-free endpoints
E ::= ;
// --- update receive definitions --- // --- receive definitions ---
// Error: there must not be two receive definitions for the same token // Error: there must not be two receive definitions for the same token
receive B.DoubledValue ; receive B.DoubledValue ;
receive B.DoubledValue using IntToInt ; receive B.DoubledValue using IntToInt ;
...@@ -18,22 +18,26 @@ receive B.ErrorTypeOfLastMapping using StringToList ; ...@@ -18,22 +18,26 @@ receive B.ErrorTypeOfLastMapping using StringToList ;
// Error: types of mappings must match (modulo inheritance) // Error: types of mappings must match (modulo inheritance)
receive B.ErrorTypeMismatch using StringToList, IntToInt ; receive B.ErrorTypeMismatch using StringToList, IntToInt ;
// --- update send definitions --- // Error: Context-Free endpoint not allowed for root nodes
receive A;
// Error: Clash with implied endpoint definition of context-free endpoint
receive E;
receive A.E;
// --- send definitions ---
// NOT HANDLED \\ Error: the token must be resolvable within the parent type // NOT HANDLED \\ Error: the token must be resolvable within the parent type
// NOT HANDLED \\ receive C.NonExisting ; // NOT HANDLED \\ receive C.NonExisting ;
// Error: Token must be a TokenNTA (i.e., check for Token.getNTA()) // NOT HANDLED \\ // Error: from-type of first mapping must be type of Token
send C.ErrorNotNTA ; // NOT HANDLED \\ send C.ErrorTypeOfFirstMapping using IntToInt ;
// Error: from-type of first mapping must be type of Token // NOT HANDLED \\ // Error: to-type of last mapping must be byte[] or a supported primitive type
send C.ErrorTypeOfFirstMapping using IntToInt ; // NOT HANDLED \\ send C.ErrorTypeOfLastMapping1 using StringToList ;
// NOT HANDLED \\ send C.ErrorTypeOfLastMapping2 ;
// Error: to-type of last mapping must be byte[] or a supported primitive type // NOT HANDLED \\ // Error: types of mappings must match (modulo inheritance)
send C.ErrorTypeOfLastMapping1 using StringToList ; // NOT HANDLED \\ send C.ErrorTypeMismatch using StringToList, IntToInt ;
send C.ErrorTypeOfLastMapping2 ;
// Error: types of mappings must match (modulo inheritance)
send C.ErrorTypeMismatch using StringToList, IntToInt ;
// Error: no more than one send mapping for each TokenComponent // Error: no more than one send mapping for each TokenComponent
send C.DoubledValue ; send C.DoubledValue ;
...@@ -44,8 +48,8 @@ send C.DoubledValue using IntToInt ; ...@@ -44,8 +48,8 @@ send C.DoubledValue using IntToInt ;
// NOT HANDLED \\ D.SourceNonExistingTarget canDependOn D.NonExisting as NonExistingTarget ; // NOT HANDLED \\ D.SourceNonExistingTarget canDependOn D.NonExisting as NonExistingTarget ;
// NOT HANDLED \\ D.NonExisting canDependOn D.TargetNonExistingSource as NonExistingSource ; // NOT HANDLED \\ D.NonExisting canDependOn D.TargetNonExistingSource as NonExistingSource ;
// Error: There must be a send update definition for the target token // NOT HANDLED \\ // Error: There must be a send update definition for the target token
D.SourceNoWriteDef canDependOn D.TargetNoWriteDef as NoWriteDef ; // NOT HANDLED \\ D.SourceNoWriteDef canDependOn D.TargetNoWriteDef as NoWriteDef ;
// Error: The name of a dependency definition must not be equal to a list-node on the source // Error: The name of a dependency definition must not be equal to a list-node on the source
D.SourceSameAsListNode canDependOn D.TargetSameAsListNode as MyList ; D.SourceSameAsListNode canDependOn D.TargetSameAsListNode as MyList ;
......
...@@ -5,7 +5,9 @@ Standard.connect Line 13, column 1: No suitable default mapping found for type j ...@@ -5,7 +5,9 @@ Standard.connect Line 13, column 1: No suitable default mapping found for type j
Standard.connect Line 13, column 1: to-type of last mapping (java.util.List) not assignable to type of the token (String)! Standard.connect Line 13, column 1: to-type of last mapping (java.util.List) not assignable to type of the token (String)!
Standard.connect Line 16, column 1: to-type of last mapping (List) not assignable to type of the token (String)! Standard.connect Line 16, column 1: to-type of last mapping (List) not assignable to type of the token (String)!
Standard.connect Line 19, column 1: to-type of last mapping (int) not assignable to type of the token (String)! Standard.connect Line 19, column 1: to-type of last mapping (int) not assignable to type of the token (String)!
Standard.connect Line 39, column 1: Endpoint definition already defined for C.DoubledValue Standard.connect Line 22, column 9: Context-Free endpoint not allowed for root node A!
Standard.connect Line 40, column 1: Endpoint definition already defined for C.DoubledValue Standard.connect Line 26, column 1: Clash with implied, indexed endpoint definition of context-free endpoint in line 25!
Standard.connect Line 51, column 1: The name of a dependency definition must not be equal to a list-node on the source Standard.connect Line 43, column 1: Endpoint definition already defined for C.DoubledValue
Standard.connect Line 56, column 1: Dependency definition already defined for D with name DoubledValue Standard.connect Line 44, column 1: Endpoint definition already defined for C.DoubledValue
Standard.connect Line 55, column 1: The name of a dependency definition must not be equal to a list-node on the source
Standard.connect Line 60, column 1: Dependency definition already defined for D with name DoubledValue
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment