Skip to content

Commit

Permalink
feat: add string content
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed May 24, 2024
1 parent 7b60039 commit 2913d24
Show file tree
Hide file tree
Showing 5 changed files with 2,895 additions and 2,865 deletions.
17 changes: 7 additions & 10 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ module.exports = grammar({
immediate_child($._named_node_expression),
),

_string: $ => seq(
'"',
repeat(choice(
token.immediate(prec(PREC.STRING, /[^"\\]+/)),
$.escape_sequence,
)),
'"',
),
// Taken from https://github.com/tree-sitter/tree-sitter-javascript/blob/3f8b62f9befd3cb3b4cb0de22f6595a0aadf76ca/grammar.js#L827
escape_sequence: _ => token.immediate(seq(
'\\',
Expand All @@ -75,7 +67,12 @@ module.exports = grammar({
_immediate_identifier: $ => alias(token.immediate(IDENTIFIER), $.identifier),
_node_identifier: $ => choice($.identifier, prec(PREC.WILDCARD_NODE, "_")),
capture: $ => seq("@", field("name", $._immediate_identifier)),
string: $ => $._string,
string: $ => seq(
'"',
optional($.string_content),
'"',
),
string_content: $ => repeat1(choice(token.immediate(prec(PREC.STRING, /[^"\\]+/)), $.escape_sequence)),
parameters: $ => repeat1(choice($.capture, $.string, $._node_identifier)),
comment: _ => token(prec(PREC.COMMENT, seq(";", /.*/))),
list: $ => seq("[", repeat($.definition), "]", quantifier($), captures($)),
Expand All @@ -89,7 +86,7 @@ module.exports = grammar({
),

anonymous_node: $ => seq(
field("name", choice(alias($._string, $.identifier), "_")),
field("name", choice(alias($.string, $.identifier), "_")),
quantifier($),
captures($),
),
Expand Down
86 changes: 47 additions & 39 deletions src/grammar.json

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

19 changes: 17 additions & 2 deletions src/node-types.json

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

Loading

0 comments on commit 2913d24

Please sign in to comment.