Skip to content

Commit

Permalink
misc fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Jul 29, 2024
1 parent 20fb336 commit adcee93
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 36 deletions.
8 changes: 4 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1201,27 +1201,27 @@ module.exports = grammar({
choice(
seq(
"`",
field("content", token.immediate(prec(1, /[^`]*/))),
token.immediate(prec(1, /[^`]*/)),
token.immediate(/`[cdw]?/),
),
seq(
'r"',
field("content", token.immediate(prec(1, /[^"]*/))),
token.immediate(prec(1, /[^"]*/)),
token.immediate(/"[cdw]?/),
),
),

hex_string: ($) =>
seq(
'x"',
field("content", token.immediate(prec(1, /[0-9A-Fa-f\s]*/))),
token.immediate(prec(1, /[0-9A-Fa-f\s]*/)),
token.immediate(/"[cdw]?/),
),

quoted_string: ($) =>
seq(
'"',
field("content", repeat(choice(/[^"\\]+/, $.escape_sequence))),
repeat(choice(/[^"\\]+/, $.escape_sequence)),
token.immediate(/"[cdw]?/),
),

Expand Down
4 changes: 2 additions & 2 deletions queries/nova-highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(float_literal) @value.number
(char_literal) @value.number ; not sure what is best for this
(special_keyword) @value.symbols
(htmlenttity) @value.entity
(htmlentity) @value.entity
(escape_sequence) @value.entity

[
Expand Down Expand Up @@ -254,7 +254,7 @@
(version_specification (version) (int_literal) @invalid) ; deprecated in 2.101
(version_condition (identifier) @value.symbol)

(module_fqn) @cdata ; this is a crummy workaround since we don't have anything for imports
(module_fqn) @processing ; this is a crummy workaround since we don't have anything for imports
(module_declaration (module_fqn)) @definition.package
(class_declaration (identifier) @identifier.type.class)
(struct_declaration (identifier) @identifier.type.struct)
Expand Down
28 changes: 12 additions & 16 deletions src/grammar.json

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

21 changes: 10 additions & 11 deletions src/node-types.json

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

4 changes: 2 additions & 2 deletions src/parser.c

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

20 changes: 19 additions & 1 deletion test/corpus/quotedstring.scm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ auto s3 = "a\u1234b\\";
================================================================================
Quoted String with Character Entity
================================================================================
auto s3 = "a\&trademark;";
auto s3 = "a\&trademark;over";

--------------------------------------------------------------------------------

Expand Down Expand Up @@ -91,3 +91,21 @@ auto s10 = "🥂"w;
(identifier)
(string_literal
(quoted_string))))

================================================================================
Quoted String with Entity
================================================================================

auto s10 = "alpha\ beta"w;

--------------------------------------------------------------------------------

(source_file
(auto_declaration
(storage_class
(auto))
(identifier)
(string_literal
(quoted_string
(escape_sequence
(htmlentity))))))

0 comments on commit adcee93

Please sign in to comment.