Skip to content

Commit cac13c4

Browse files
authored
Fix parsing of strings with two slashes (#27)
Also, add more tests around strings
1 parent 5bb7df9 commit cac13c4

File tree

8 files changed

+24553
-24061
lines changed

8 files changed

+24553
-24061
lines changed

grammar.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ module.exports = grammar({
5959
name: 'pkl',
6060

6161
externals: $ => [
62+
$._sl_string_chars,
6263
$._sl1_string_chars,
6364
$._sl2_string_chars,
6465
$._sl3_string_chars,
@@ -553,7 +554,7 @@ module.exports = grammar({
553554
),
554555
),
555556

556-
slStringLiteralPart: $ => token.immediate(/[^"\\\n\r]+/),
557+
slStringLiteralPart: $ => $._sl_string_chars,
557558

558559
slStringLiteralPart1: $ => $._sl1_string_chars,
559560

src/grammar.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,11 +2443,8 @@
24432443
]
24442444
},
24452445
"slStringLiteralPart": {
2446-
"type": "IMMEDIATE_TOKEN",
2447-
"content": {
2448-
"type": "PATTERN",
2449-
"value": "[^\"\\\\\\n\\r]+"
2450-
}
2446+
"type": "SYMBOL",
2447+
"name": "_sl_string_chars"
24512448
},
24522449
"slStringLiteralPart1": {
24532450
"type": "SYMBOL",
@@ -3281,8 +3278,12 @@
32813278
"name": "identifier"
32823279
},
32833280
{
3284-
"type": "STRING",
3285-
"value": "\n"
3281+
"type": "FIELD",
3282+
"name": "err",
3283+
"content": {
3284+
"type": "STRING",
3285+
"value": "\n"
3286+
}
32863287
}
32873288
]
32883289
}
@@ -4220,6 +4221,10 @@
42204221
],
42214222
"precedences": [],
42224223
"externals": [
4224+
{
4225+
"type": "SYMBOL",
4226+
"name": "_sl_string_chars"
4227+
},
42234228
{
42244229
"type": "SYMBOL",
42254230
"name": "_sl1_string_chars"

src/node-types.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4049,6 +4049,16 @@
40494049
"type": "propertyCallExpr",
40504050
"named": true,
40514051
"fields": {
4052+
"err": {
4053+
"multiple": false,
4054+
"required": false,
4055+
"types": [
4056+
{
4057+
"type": "\n",
4058+
"named": false
4059+
}
4060+
]
4061+
},
40524062
"receiver": {
40534063
"multiple": false,
40544064
"required": true,

0 commit comments

Comments
 (0)