Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ component grammar SysMLExpressions
* name of the function to be invoked and an argument list for any remaining arguments (see 7.4.9.4). This is
* useful for chaining invocations in an effective data flow
*/
SysMLFunctionOperationExpression implements Expression =
SysMLFunctionOperationExpression implements Expression <291> =
Expression "->" Name ("(" (SysMLParameter || ",")* ")")? ("{" SysMLElement* inner:Expression "}")? ;

// Eigentlich ist "^" der Name einer CalcDef aus den Domain Libraries
Expand Down
45 changes: 45 additions & 0 deletions language/src/test/java/parser/ExpressionParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.monticore.expressions.commonexpressions._ast.ASTCallExpression;
import de.monticore.lang.sysmlexpressions._ast.ASTElementOfExpression;
import de.monticore.lang.sysmlexpressions._ast.ASTSysMLFunctionOperationExpression;
import de.monticore.lang.sysmlexpressions._ast.ASTSysMLInstantiation;
import de.monticore.lang.sysmlv2.SysMLv2Mill;
import de.monticore.lang.sysmlv2._parser.SysMLv2Parser;
Expand Down Expand Up @@ -82,4 +83,48 @@ public void testElementOf() throws IOException {
assertThat(ast.get()).isInstanceOf(ASTElementOfExpression.class);
}

/**
* Checks if SysMLFunctionOperatorExpressions are parsed without being
* wrapped within a Call Expression
*/
@Test
public void testSysMLFunctionOperatorExprMinimal() throws IOException {
var ast = parser.parse_StringExpression("x->b()");

assertThat(ast).isPresent();
assertThat(Log.getFindings()).isEmpty();
// We do expect: SysMLFunctionOperatorExpression with an inner
// expression, name and parameters
assertThat(ast.get()).isInstanceOf(ASTSysMLFunctionOperationExpression.class);
}

/**
* Checks if SysMLFunctionOperatorExpressions are parsed without being
* wrapped within a Call Expression
*/
@Test
public void testSysMLFunctionOperatorExpr() throws IOException {
var ast = parser.parse_StringExpression("x->excludes(y)");

assertThat(ast).isPresent();
assertThat(Log.getFindings()).isEmpty();
// We do expect: SysMLFunctionOperatorExpression with an inner
// expression, name and parameters
assertThat(ast.get()).isInstanceOf(ASTSysMLFunctionOperationExpression.class);
}

@Test
public void testSysMLFunctionOperatorExpr2() throws IOException {
var ast = parser.parse_StringExpression("x->excludes(y.z)");

assertThat(ast).isPresent();
assertThat(Log.getFindings()).isEmpty();
// We do expect: SysMLFunctionOperatorExpression with an inner
// expression, name and parameters
// currently the parameters are separated in an outer CallExpr
assertThat(ast.get()).isInstanceOf(ASTSysMLFunctionOperationExpression.class);
}

// ReachableStates(c.behavior, input2.values())->excludes(SecurityGate_LLR.behavior.Bob_Alice_Eve)

}
Loading