Skip to content

Commit 42a1542

Browse files
authored
Merge pull request #462 from tree-sitter/generation
chore: generate and sync latest changes
2 parents 774d1cb + b5a23fb commit 42a1542

File tree

5 files changed

+559738
-538779
lines changed

5 files changed

+559738
-538779
lines changed

grammar.js

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,13 +1630,17 @@ module.exports = grammar({
16301630
),
16311631
),
16321632

1633-
interpolated_string_expression: $ =>
1634-
choice(
1635-
seq(field("interpolator", alias($._raw_string_start, $.identifier)), alias($._raw_string, $.interpolated_string)),
1636-
seq(field("interpolator", $.identifier), $.interpolated_string),
1633+
interpolated_string_expression: $ =>
1634+
choice(
1635+
seq(
1636+
field("interpolator", alias($._raw_string_start, $.identifier)),
1637+
alias($._raw_string, $.interpolated_string),
1638+
),
1639+
seq(field("interpolator", $.identifier), $.interpolated_string),
16371640
),
16381641

1639-
_dollar_escape: $ => alias(token(seq("$", choice("$", '"'))), $.escape_sequence),
1642+
_dollar_escape: $ =>
1643+
alias(token(seq("$", choice("$", '"'))), $.escape_sequence),
16401644

16411645
_aliased_interpolation_identifier: $ =>
16421646
alias($._interpolation_identifier, $.identifier),
@@ -1670,14 +1674,14 @@ module.exports = grammar({
16701674
),
16711675

16721676
// We need to handle single-line raw strings separately from interpolated strings,
1673-
// because raw strings are not parsed for escape sequences. For example, raw strings
1677+
// because raw strings are not parsed for escape sequences. For example, raw strings
16741678
// are often used for regular expressions, which contain backslashes that would
16751679
// be invalid if parsed as escape sequences. We do not special case multiline
16761680
// raw strings, because multiline strings do not parse escape sequences anyway.
16771681
// Scala handles multiline raw strings identically to other multiline interpolated,
16781682
// so we could parse them as interpolated strings, but I think the code is cleaner
16791683
// if we maintain the distinction.
1680-
_raw_string: $ =>
1684+
_raw_string: $ =>
16811685
choice(
16821686
seq(
16831687
$._simple_string_start,
@@ -1689,46 +1693,50 @@ module.exports = grammar({
16891693
),
16901694
),
16911695
$._single_line_string_end,
1692-
),
1696+
),
16931697
),
16941698
seq(
16951699
$._simple_multiline_string_start,
16961700
repeat(
16971701
seq(
16981702
$._raw_string_multiline_middle,
16991703
choice($._dollar_escape, $.interpolation),
1700-
)
1704+
),
17011705
),
17021706
$._multiline_string_end,
17031707
),
17041708
),
17051709

1706-
escape_sequence: _ => token.immediate(seq(
1707-
'\\',
1708-
choice(
1709-
/[tbnrf"'\\]/,
1710-
// The Java spec allows any number of u's and U's at the start of a unicode escape.
1711-
/[uU]+[0-9a-fA-F]{4}/,
1712-
// Octals are not allowed in Scala 3, but are allowed in Scala 2. tree-sitter
1713-
// does not have a mechanism for distinguishing between different versions of a
1714-
// language, so I think it makes sense to allow them. Maybe in the future we
1715-
// should move them to a `deprecated` syntax node?
1716-
/[0-3]?[0-7]{1,2}/,
1717-
),
1718-
)),
1719-
1720-
string: $ => choice(
1721-
seq(
1722-
$._simple_string_start,
1723-
repeat(seq($._simple_string_middle, $.escape_sequence)),
1724-
$._single_line_string_end,
1710+
escape_sequence: _ =>
1711+
token.immediate(
1712+
seq(
1713+
"\\",
1714+
choice(
1715+
/[tbnrf"'\\]/,
1716+
// The Java spec allows any number of u's and U's at the start of a unicode escape.
1717+
/[uU]+[0-9a-fA-F]{4}/,
1718+
// Octals are not allowed in Scala 3, but are allowed in Scala 2. tree-sitter
1719+
// does not have a mechanism for distinguishing between different versions of a
1720+
// language, so I think it makes sense to allow them. Maybe in the future we
1721+
// should move them to a `deprecated` syntax node?
1722+
/[0-3]?[0-7]{1,2}/,
1723+
),
1724+
),
17251725
),
1726-
seq(
1727-
$._simple_multiline_string_start,
1728-
/// Multiline strings ignore escape sequences
1729-
$._multiline_string_end,
1726+
1727+
string: $ =>
1728+
choice(
1729+
seq(
1730+
$._simple_string_start,
1731+
repeat(seq($._simple_string_middle, $.escape_sequence)),
1732+
$._single_line_string_end,
1733+
),
1734+
seq(
1735+
$._simple_multiline_string_start,
1736+
/// Multiline strings ignore escape sequences
1737+
$._multiline_string_end,
1738+
),
17301739
),
1731-
),
17321740

17331741
_semicolon: $ => choice(";", $._automatic_semicolon),
17341742

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)