Skip to content

Commit 72bf3a1

Browse files
committed
Handle newlines after pair-keys
1 parent 4a7d06b commit 72bf3a1

File tree

4 files changed

+293977
-293777
lines changed

4 files changed

+293977
-293777
lines changed

grammar.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module.exports = grammar({
3636
inline: $ => [$._arg_rhs, $._call_operator],
3737
externals: $ => [
3838
$._line_break,
39+
$._no_line_break,
3940

4041
// Delimited literals
4142
$.simple_symbol,
@@ -1177,7 +1178,12 @@ module.exports = grammar({
11771178
alias($.constant_suffix, $.hash_key_symbol),
11781179
)),
11791180
token.immediate(':'),
1180-
field('value', optional($._arg))
1181+
choice(
1182+
field('value', optional($._arg)),
1183+
// This alternative never matches, because '_no_line_break' tokens do not exist.
1184+
// The purpose is give a hint to the scanner that it should not produce any line-break
1185+
// terminators at this point.
1186+
$._no_line_break)
11811187
)
11821188
)),
11831189

src/grammar.json

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7695,20 +7695,29 @@
76957695
}
76967696
},
76977697
{
7698-
"type": "FIELD",
7699-
"name": "value",
7700-
"content": {
7701-
"type": "CHOICE",
7702-
"members": [
7703-
{
7704-
"type": "SYMBOL",
7705-
"name": "_arg"
7706-
},
7707-
{
7708-
"type": "BLANK"
7698+
"type": "CHOICE",
7699+
"members": [
7700+
{
7701+
"type": "FIELD",
7702+
"name": "value",
7703+
"content": {
7704+
"type": "CHOICE",
7705+
"members": [
7706+
{
7707+
"type": "SYMBOL",
7708+
"name": "_arg"
7709+
},
7710+
{
7711+
"type": "BLANK"
7712+
}
7713+
]
77097714
}
7710-
]
7711-
}
7715+
},
7716+
{
7717+
"type": "SYMBOL",
7718+
"name": "_no_line_break"
7719+
}
7720+
]
77127721
}
77137722
]
77147723
}
@@ -7823,6 +7832,10 @@
78237832
"type": "SYMBOL",
78247833
"name": "_line_break"
78257834
},
7835+
{
7836+
"type": "SYMBOL",
7837+
"name": "_no_line_break"
7838+
},
78267839
{
78277840
"type": "SYMBOL",
78287841
"name": "simple_symbol"

0 commit comments

Comments
 (0)