Skip to content

Commit

Permalink
feat: separate field + node to access strings content
Browse files Browse the repository at this point in the history
  • Loading branch information
ahlinc committed Sep 22, 2021
1 parent 7776f24 commit e25efde
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,10 @@ module.exports = grammar({

_special_character: $ => token(prec(-1, choice('{', '}', '[', ']'))),

string: $ => seq(
'"',
repeat(seq(
string: $ => seq('"', field('content', optional($.str)), '"'),

str: $ => seq(
repeat1(seq(
choice(
seq(optional('$'), $._string_content),
$.expansion,
Expand All @@ -462,7 +463,6 @@ module.exports = grammar({
optional($._concat)
)),
optional('$'),
'"'
),

_string_content: $ => token(prec(-1, /([^"`$\\]|\\(.|\n))+/)),
Expand All @@ -473,9 +473,9 @@ module.exports = grammar({
')'
),

raw_string: $ => /'[^']*'/,
raw_string: $ => seq("'", field('content', optional(alias(/[^']+/, $.str))), "'"),

ansii_c_string: $ => /\$'([^']|\\')*'/,
ansii_c_string: $ => seq("\$'", field('content', optional(alias(/([^']|\\')+/, $.str))), "'"),

simple_expansion: $ => seq(
'$',
Expand Down

0 comments on commit e25efde

Please sign in to comment.