Skip to content

Commit

Permalink
Update string interpolation syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
irh committed Apr 4, 2024
1 parent aef3fee commit ed09708
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
3 changes: 1 addition & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,8 @@ module.exports = grammar({
$._string_start,
repeat(choice(
$.escape,
seq('$', $.identifier),
seq(
"${",
"{",
$._interpolation_start,
optional($._expressions),
$._interpolation_end,
Expand Down
4 changes: 2 additions & 2 deletions src/grammar.json
Git LFS file not shown
4 changes: 2 additions & 2 deletions src/node-types.json
Git LFS file not shown
4 changes: 2 additions & 2 deletions src/parser.c
Git LFS file not shown
14 changes: 7 additions & 7 deletions test/corpus/strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ string"
string_interpolated
===========================================================================================

'foo is $foo'
'foo, bar is ${foo, bar}'
'inline comment in expression ${foo, #- bar -# bar}'
'foo is {foo}'
'foo, bar is {foo, bar}'
'inline comment in expression {foo, #- bar -# bar}'

---

Expand All @@ -69,7 +69,7 @@ string_interpolated
escapes
===========================================================================================

'foo\n\t\r\\\$bar'
'foo\n\t\r\\\{bar'
'\'\'\''
"\"''\""
'\x4e foo \xF9'
Expand Down Expand Up @@ -114,7 +114,7 @@ escapes
raw_strings
===========================================================================================

r'$foo\r\n'
r'{foo}\r\n'
r"'\#"
r#""bar""#
r##"#"hi"#"##
Expand All @@ -132,8 +132,8 @@ r##"#"hi"#"##
incomplete_string_interpolation
===========================================================================================

'${} x'
'y ${'
'{} x'
'y {'

---

Expand Down

0 comments on commit ed09708

Please sign in to comment.