Skip to content

Commit

Permalink
🐛 Support empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Apr 11, 2024
1 parent 2f918f9 commit 138ee30
Show file tree
Hide file tree
Showing 4 changed files with 8,967 additions and 9,809 deletions.
8 changes: 3 additions & 5 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ module.exports = grammar({
optional($._attributes),
$.foreground,
$.background,
$._regex
optional($._regex)
),
seq(
"compose",
Expand Down Expand Up @@ -467,17 +467,15 @@ module.exports = grammar({
quoted_string('"', $.shell),
quoted_string("`", $.shell),
alias($._word, $.shell),
"\n"
),
_regex: ($) =>
choice(
quoted_string("'", $.regex),
quoted_string('"', $.regex),
quoted_string("`", $.shell),
alias($._word, $.regex),
"\n"
),
_word: (_) => /(\\\r?\n|[^"'`\s])(\S|\\\s)*/,
_word: (_) => /([^"'`\s])(\S|\\\s)*/,

source_directive: ($) => command($, "source", alias($._string, $.path)),

Expand Down Expand Up @@ -508,7 +506,7 @@ function quoted_string(char, name) {
return seq(
char,
alias(
field("content", new RegExp("([^" + char + "]|\\\\" + char + ")+")),
field("content", new RegExp("([^" + char + "]|\\\\" + char + ")*")),
name
),
char
Expand Down
54 changes: 19 additions & 35 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 138ee30

Please sign in to comment.