Skip to content
Open
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 @@ -119,7 +119,7 @@ component grammar SysMLExpressions

SysMLFunctionOperationExpression implements Expression <291> =
Expression "->" Name
("(" (SysMLParameter || ",")* ")")?
(Arguments)?
(body:SysMLBodyExpression)? ;

// Eigentlich ist "^" der Name einer CalcDef aus den Domain Libraries
Expand Down
18 changes: 18 additions & 0 deletions language/src/test/java/parser/ExpressionParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,22 @@ public void testFunctionOperationAfterFieldAccess() throws IOException {
assertThat(functionOperation.getName()).isEqualTo("c");
}

/**
* Checks that a function operation with arguments is parsed directly as
* ASTSysMLFunctionOperationExpression, not wrapped in an ASTCallExpression.
*/
@Test
public void testFunctionOperationWithArguments() throws IOException {
var ast = parser.parse_StringExpression("x->b(y)");

assertThat(ast).isPresent();
assertThat(Log.getFindings()).isEmpty();
assertThat(ast.get()).isInstanceOf(ASTSysMLFunctionOperationExpression.class);
assertThat(ast.get()).isNotInstanceOf(ASTCallExpression.class);

var functionOperation = (ASTSysMLFunctionOperationExpression) ast.get();
assertThat(functionOperation.getName()).isEqualTo("b");
assertThat(functionOperation.getArguments().getExpressionList()).hasSize(1);
}

}
Loading