Skip to content

Commit

Permalink
Fix: raw string with leading whitespaces (#158)
Browse files Browse the repository at this point in the history
This PR fixes #157 .
The problem is rooted in my [review
suggestion](#117 (comment)),
so the change is reverted.

But I don't get why, how is whitespaces automatically skipped by
`extras` for `$._str_double_quotes`, but not `$._raw_string`.
@mrdgo do you have any idea?

Edit: I get it wrong, the scanner is handled earlier than `extras` so it
may override the behavior of the later.
  • Loading branch information
blindFS authored Nov 28, 2024
1 parent 74e6037 commit 1c3821f
Show file tree
Hide file tree
Showing 5 changed files with 232,132 additions and 228,080 deletions.
19 changes: 9 additions & 10 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = grammar({

inline: ($) => [
$._do_expression,
$._flag,
$._flag_value,
$._item_expression,
$._match_expression,
Expand Down Expand Up @@ -273,14 +274,12 @@ module.exports = grammar({
token.immediate(BRACK().open_angle),
repeat(
seq(
seq(
key,
optional(
seq(
PUNC().colon,
$._all_type,
field("completion", optional($.param_cmd)),
),
key,
optional(
seq(
PUNC().colon,
$._all_type,
field("completion", optional($.param_cmd)),
),
),
optional(PUNC().comma),
Expand Down Expand Up @@ -419,7 +418,7 @@ module.exports = grammar({
PREC().low,
seq(
KEYWORD().do,
optional(seq(repeat($._flags_parenthesized))),
repeat($._flags_parenthesized),
repeat1($._separator),
choice($._blosure, $.val_variable),
repeat(seq(repeat($._newline), $._do_expression)),
Expand Down Expand Up @@ -1283,7 +1282,7 @@ module.exports = grammar({
),
),

_flag: ($) => prec.right(5, choice($.short_flag, $.long_flag)),
_flag: ($) => choice($.short_flag, $.long_flag),

_flags_parenthesized: ($) => seq(repeat1($._separator), $._flag),

Expand Down
149 changes: 64 additions & 85 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2955,66 +2955,61 @@
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "key",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "val_string"
},
"named": true,
"value": "identifier"
}
]
"type": "FIELD",
"name": "key",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "val_string"
},
"named": true,
"value": "identifier"
}
},
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "_all_type"
},
{
"type": "FIELD",
"name": "completion",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "param_cmd"
},
{
"type": "BLANK"
}
]
}
}
]
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "_all_type"
},
{
"type": "BLANK"
"type": "FIELD",
"name": "completion",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "param_cmd"
},
{
"type": "BLANK"
}
]
}
}
]
},
{
"type": "BLANK"
}
]
},
Expand Down Expand Up @@ -3598,24 +3593,11 @@
"value": "do"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_flags_parenthesized"
}
}
]
},
{
"type": "BLANK"
}
]
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_flags_parenthesized"
}
},
{
"type": "REPEAT1",
Expand Down Expand Up @@ -14971,21 +14953,17 @@
]
},
"_flag": {
"type": "PREC_RIGHT",
"value": 5,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "short_flag"
},
{
"type": "SYMBOL",
"name": "long_flag"
}
]
}
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "short_flag"
},
{
"type": "SYMBOL",
"name": "long_flag"
}
]
},
"_flags_parenthesized": {
"type": "SEQ",
Expand Down Expand Up @@ -16111,6 +16089,7 @@
],
"inline": [
"_do_expression",
"_flag",
"_flag_value",
"_item_expression",
"_match_expression",
Expand Down
Loading

0 comments on commit 1c3821f

Please sign in to comment.