Skip to content

Commit

Permalink
fix: correct raw string literal parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Nov 24, 2024
1 parent 38154b9 commit c0ac7e5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ module.exports = grammar({

raw_string_literal: $ => seq(
'`',
alias(/[^`]*/, $.raw_string_literal_content),
alias(token(prec(1, /[^`]*/)), $.raw_string_literal_content),
'`',
),

Expand Down
11 changes: 9 additions & 2 deletions src/grammar.json

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

26 changes: 13 additions & 13 deletions src/parser.c

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

11 changes: 9 additions & 2 deletions test/corpus/literals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ const (
a = "0"
b = "`\"`"
c = "\x0c"
d = "errorstring
d = `//`
e = "errorstring
"
)

Expand All @@ -310,7 +311,8 @@ const (
(const_spec
(identifier)
(expression_list
(interpreted_string_literal (interpreted_string_literal_content))))
(interpreted_string_literal
(interpreted_string_literal_content))))
(const_spec
(identifier)
(expression_list
Expand All @@ -323,6 +325,11 @@ const (
(expression_list
(interpreted_string_literal
(escape_sequence))))
(const_spec
(identifier)
(expression_list
(raw_string_literal
(raw_string_literal_content))))
(ERROR
(identifier)
(interpreted_string_literal_content))))
Expand Down

0 comments on commit c0ac7e5

Please sign in to comment.