-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: syntax and formatting for literal types (#529)
Closes partially #80. ### Summary of Changes * Add syntax for literal types: ``` literal<1, 1.0, true, false, null, ""> ``` * Update formatter to handle literal types --------- Co-authored-by: megalinter-bot <[email protected]>
- Loading branch information
1 parent
e204fe9
commit 32aca34
Showing
20 changed files
with
143 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ coverage/ | |
dist/ | ||
dist-ssr/ | ||
out/ | ||
DSL/syntaxes/safe-ds.tmLanguage.json | ||
|
||
# Node | ||
.npm/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
DSL/tests/resources/formatting/trailing commas/literal list of literal type.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
segment s( | ||
f: literal<1.0 , null , > | ||
) {} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
segment s( | ||
f: literal<1.0, null,> | ||
) {} |
5 changes: 5 additions & 0 deletions
5
DSL/tests/resources/formatting/types/literal types/empty.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
segment mySegment(x: literal < >) {} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
segment mySegment(x: literal<>) {} |
9 changes: 9 additions & 0 deletions
9
DSL/tests/resources/formatting/types/literal types/with literals.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
segment mySegment( | ||
x: literal < 1.0 , null > | ||
) {} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
segment mySegment( | ||
x: literal<1.0, null> | ||
) {} |
9 changes: 9 additions & 0 deletions
9
...ources/formatting/types/member types/receiver (literal) and member (not nullable).sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
segment mySegment( | ||
x: literal < > . InnerClass | ||
) {} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
segment mySegment( | ||
x: literal<>.InnerClass | ||
) {} |
9 changes: 9 additions & 0 deletions
9
.../resources/formatting/types/member types/receiver (literal) and member (nullable).sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
segment mySegment( | ||
x: literal < > . InnerClass ? | ||
) {} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
segment mySegment( | ||
x: literal<>.InnerClass? | ||
) {} |
3 changes: 3 additions & 0 deletions
3
DSL/tests/resources/grammar/keywords as names/bad-unescaped literal.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// $TEST$ syntax_error | ||
|
||
class literal |
5 changes: 5 additions & 0 deletions
5
DSL/tests/resources/grammar/trailing commas/good-literal list of literal type.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
segment s( | ||
f: literal<true, false, > | ||
) {} |
5 changes: 5 additions & 0 deletions
5
DSL/tests/resources/grammar/types/literal types/bad-nested.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
segment mySegment( | ||
x: literal<literal<>> | ||
) {} |
5 changes: 5 additions & 0 deletions
5
DSL/tests/resources/grammar/types/literal types/bad-unclosed angle bracket.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
segment mySegment( | ||
x: literal< | ||
) {} |
5 changes: 5 additions & 0 deletions
5
DSL/tests/resources/grammar/types/literal types/good-empty.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
segment mySegment( | ||
x: literal<> | ||
) {} |
5 changes: 5 additions & 0 deletions
5
DSL/tests/resources/grammar/types/literal types/good-with literals.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
segment mySegment( | ||
x: literal<null, true, false, 1, 1.0, "s"> | ||
) {} |
5 changes: 5 additions & 0 deletions
5
DSL/tests/resources/grammar/types/member types/bad-literal type as member.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
segment mySegment( | ||
x: OuterClass.literal<> | ||
) {} |
5 changes: 5 additions & 0 deletions
5
...rces/grammar/types/member types/good-receiver (literal) and member (not nullable).sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
segment mySegment( | ||
x: literal<>.InnerClass | ||
) {} |
5 changes: 5 additions & 0 deletions
5
...esources/grammar/types/member types/good-receiver (literal) and member (nullable).sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
segment mySegment( | ||
x: literal<>.InnerClass? | ||
) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,6 @@ export default defineConfig({ | |
include: ['src'], | ||
exclude: ['**/generated'], | ||
}, | ||
exclude: ['out'], | ||
}, | ||
}); |