Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove type arguments from calls #581

Merged
merged 5 commits into from
Sep 29, 2023
Merged
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
1 change: 0 additions & 1 deletion src/language/formatting/safe-ds-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ export class SafeDsFormatter extends AbstractFormatter {
private formatSdsCall(node: ast.SdsCall) {
const formatter = this.getNodeFormatter(node);

formatter.property('typeArgumentList').prepend(noSpace());
formatter.property('argumentList').prepend(noSpace());
}

Expand Down
45 changes: 6 additions & 39 deletions src/language/grammar/safe-ds.langium
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ SdsComparisonExpression returns SdsExpression:
;

SdsComparisonOperator returns string:
LESS_THAN | '<=' | '>=' | '>'
'<' | '<=' | '>=' | '>'
;

SdsAdditiveExpression returns SdsExpression:
Expand Down Expand Up @@ -644,9 +644,7 @@ interface SdsChainedExpression extends SdsExpression {
receiver: SdsExpression
}

interface SdsCall extends SdsAbstractCall, SdsChainedExpression {
typeArgumentList?: SdsTypeArgumentList
}
interface SdsCall extends SdsAbstractCall, SdsChainedExpression {}

interface SdsIndexedAccess extends SdsChainedExpression {
index: SdsExpression
Expand All @@ -661,7 +659,6 @@ SdsChainedExpression returns SdsExpression:
SdsPrimaryExpression
(
{SdsCall.receiver=current}
typeArgumentList=SdsCallTypeArgumentList?
argumentList=SdsCallArgumentList

| {SdsIndexedAccess.receiver=current}
Expand Down Expand Up @@ -856,7 +853,7 @@ interface SdsLiteralList extends SdsObject {

SdsLiteralList returns SdsLiteralList:
{SdsLiteralList}
(LESS_THAN | CALL_TYPE_ARGUMENT_LIST_START)
'<'
(
literals+=SdsLiteral
(',' literals+=SdsLiteral)*
Expand Down Expand Up @@ -887,7 +884,7 @@ SdsUnionType returns SdsUnionType:

SdsUnionTypeArgumentList returns SdsTypeArgumentList:
{SdsTypeArgumentList}
(LESS_THAN | CALL_TYPE_ARGUMENT_LIST_START)
'<'
(
typeArguments+=SdsUnionTypeArgument
(',' typeArguments+=SdsUnionTypeArgument)*
Expand All @@ -914,7 +911,7 @@ interface SdsTypeParameterList extends SdsObject {

SdsTypeParameterList returns SdsTypeParameterList:
{SdsTypeParameterList}
(LESS_THAN | CALL_TYPE_ARGUMENT_LIST_START)
'<'
(
typeParameters+=SdsTypeParameter
(',' typeParameters+=SdsTypeParameter)*
Expand Down Expand Up @@ -943,14 +940,7 @@ interface SdsTypeArgumentList extends SdsObject {

SdsTypeArgumentList returns SdsTypeArgumentList:
{SdsTypeArgumentList}
(LESS_THAN | CALL_TYPE_ARGUMENT_LIST_START)
(typeArguments+=SdsTypeArgument (',' typeArguments+=SdsTypeArgument)* ','? )?
'>'
;

SdsCallTypeArgumentList returns SdsTypeArgumentList:
{SdsTypeArgumentList}
CALL_TYPE_ARGUMENT_LIST_START
'<'
(typeArguments+=SdsTypeArgument (',' typeArguments+=SdsTypeArgument)* ','? )?
'>'
;
Expand Down Expand Up @@ -1040,29 +1030,6 @@ terminal TEMPLATE_STRING_START returns string: STRING_START STRING_TEXT* TEMPLAT
terminal TEMPLATE_STRING_INNER returns string: TEMPLATE_EXPRESSION_END STRING_TEXT* TEMPLATE_EXPRESSION_START;
terminal TEMPLATE_STRING_END returns string: TEMPLATE_EXPRESSION_END STRING_TEXT* STRING_END;

// Resolves the ambiguity between the less than operator (<) and the start of a type argument list of a call (<).
// See also: https://github.com/langium/langium/discussions/921#discussioncomment-4943180
terminal CALL_TYPE_ARGUMENT_LIST_START:
'<'
(?=
/[\s»«]*/
( '*' // Star projection as positional type argument
| 'in' // Contravariant type projection as positional type argument
| 'out' // Covariant type projection as positional type argument
| 'literal' // Invariant literal type as positional type argument
| 'union' // Invariant union type as positional type argument
| '>' // Empty type argument list
| ID /[\s»«]*/
( '=' // Named type argument
| ('.' /[\s»«]*/ ID /[\s»«]*/)* (',' | '>') // Invariant type projection as positional type argument
)
)
)
;
terminal LESS_THAN:
'<'
;

hidden terminal ML_COMMENT: /\/\*[\s\S]*?\*\//;
hidden terminal SL_COMMENT: /\/\/[^\n\r]*/;
hidden terminal TEST_MARKER: /[»«]/;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pipeline myPipeline {
f < Int > ( );
f ( 1 , b = 2 );
}

// -----------------------------------------------------------------------------

pipeline myPipeline {
f<Int>();
f(1, b = 2);
}

This file was deleted.

This file was deleted.

Loading
Loading