Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct raw string literal parsing #157

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion queries/tags.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

(type_identifier) @name @reference.type

(package_clause (package identifier) @name)
(package_clause "package" (package_identifier) @name)

(type_declaration (type_spec name: (type_identifier) @name type: (interface_type)))

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
Loading