Skip to content

Commit 3b9c623

Browse files
committed
feat: Add wildcard slice expression support
Implements wildcard slice syntax for arrays and lists: - arr.[*] selects all elements - matrix.[0.., *] for multi-dimensional slicing - Consistent with F# 6.0+ slice syntax The grammar already supported '*' in slice_range but wasn't creating a proper AST node. This change aliases '*' as wildcard_slice for clearer AST representation. Tests added for: - Simple wildcard slice: arr.[*] - 2D array row slice: matrix.[0.., *] - 2D array column slice: matrix.[*, 0..]
1 parent 5141851 commit 3b9c623

File tree

5 files changed

+5483
-5388
lines changed

5 files changed

+5483
-5388
lines changed

fsharp/grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ module.exports = grammar({
987987
),
988988
),
989989

990-
slice_range: ($) => choice($._slice_range_special, $._expression, "*"),
990+
slice_range: ($) => choice($._slice_range_special, $._expression, alias("*", $.wildcard_slice)),
991991

992992
//
993993
// Computation expression (END)

fsharp/src/grammar.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3375,8 +3375,13 @@
33753375
"name": "_expression"
33763376
},
33773377
{
3378-
"type": "STRING",
3379-
"value": "*"
3378+
"type": "ALIAS",
3379+
"content": {
3380+
"type": "STRING",
3381+
"value": "*"
3382+
},
3383+
"named": true,
3384+
"value": "wildcard_slice"
33803385
}
33813386
]
33823387
},

fsharp/src/node-types.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3160,6 +3160,10 @@
31603160
{
31613161
"type": "_expression",
31623162
"named": true
3163+
},
3164+
{
3165+
"type": "wildcard_slice",
3166+
"named": true
31633167
}
31643168
]
31653169
}
@@ -4522,11 +4526,11 @@
45224526
},
45234527
{
45244528
"type": "unit",
4525-
"named": true
4529+
"named": false
45264530
},
45274531
{
45284532
"type": "unit",
4529-
"named": false
4533+
"named": true
45304534
},
45314535
{
45324536
"type": "unmanaged",
@@ -4576,6 +4580,10 @@
45764580
"type": "wildcard_pattern",
45774581
"named": true
45784582
},
4583+
{
4584+
"type": "wildcard_slice",
4585+
"named": true
4586+
},
45794587
{
45804588
"type": "with",
45814589
"named": false

0 commit comments

Comments
 (0)