Skip to content

Commit

Permalink
feat: expose "string_content" child for quoted_string
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotfontaine committed Sep 27, 2024
1 parent e701e9b commit bcb02c5
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,32 +294,27 @@ module.exports = grammar({
),

quoted_string: ($) =>
token(
choice(
// Match double quotes
seq(
field("quotes_open", '"'),
alias(
repeat1(
choice(
/[^"\\\n]/, // Match any character except double quotes, backslashes, or newlines
/\\./, // Match escaped characters (e.g., \" or \')
/\\\n\s*/, // Match a backslash followed by a newline and optional spaces (line continuation)
),
choice(
// Match double quotes
seq(
field("quotes_open", '"'),
alias(
repeat1(
choice(
/[^"\\\n]/, // Match any character except double quotes, backslashes, or newlines
/\\./, // Match escaped characters (e.g., \" or \')
/\\\n\s*/, // Match a backslash followed by a newline and optional spaces (line continuation)
),
$.string_content,
),
field("quotes_close", '"'),
),
// Match single quotes
seq(
field("quotes_open", "'"),
alias(
repeat(choice(/[^'\\\n]/, /\\./, /\\\n\s*/)),
$.string_content,
),
field("quotes_close", "'"),
$.string_content,
),
field("quotes_close", '"'),
),
// Match single quotes
seq(
field("quotes_open", "'"),
alias(repeat(choice(/[^'\\\n]/, /\\./, /\\\n\s*/)), $.string_content),
field("quotes_close", "'"),
),
),

Expand Down

0 comments on commit bcb02c5

Please sign in to comment.