Skip to content

Commit 726aba0

Browse files
committed
Version 0.6.0 - add interpolated string support
This lacks any support for queries, but at least the grammar will not be utterly confused.
1 parent 143a2e6 commit 726aba0

File tree

11 files changed

+428984
-396036
lines changed

11 files changed

+428984
-396036
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tree-sitter-d"
33
description = "d grammar for the tree-sitter parsing library"
4-
version = "0.5.1"
4+
version = "0.6.0"
55
keywords = ["incremental", "parsing", "d"]
66
categories = ["parsing", "text-editors"]
77
repository = "https://github.com/gdamore/tree-sitter-d"

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ clean:
107107
test:
108108
$(TS) test
109109

110-
version: pyproject_version cargo_version
110+
version: pyproject_version cargo_version pkgconfig_version
111111

112112
pyproject_version:
113113
sed -e 's|^version = ".*"|version = "$(VERSION)"|' < pyproject.toml > pyproject.toml.new
@@ -117,4 +117,8 @@ cargo_version:
117117
sed -e 's|^version = ".*"|version = "$(VERSION)"|' < Cargo.toml > Cargo.toml.new
118118
mv Cargo.toml.new Cargo.toml
119119

120+
pkgconfig_version:
121+
sed -e 's|^Version: .*|Version: $(VERSION)|' < $(LANGUAGE_NAME).pc > $(LANGUAGE_NAME).pc.new
122+
mv $(LANGUAGE_NAME).pc.new $(LANGUAGE_NAME).pc
123+
120124
.PHONY: all install uninstall clean test version pyproject_version cargo_version

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.1
1+
0.6.0

grammar.js

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,11 +1214,7 @@ module.exports = grammar({
12141214

12151215
raw_string: ($) =>
12161216
choice(
1217-
seq(
1218-
"`",
1219-
token.immediate(prec(1, /[^`]*/)),
1220-
token.immediate(/`[cdw]?/),
1221-
),
1217+
seq("`", token.immediate(prec(1, /[^`]*/)), token.immediate(/`[cdw]?/)),
12221218
seq(
12231219
'r"',
12241220
token.immediate(prec(1, /[^"]*/)),
@@ -1240,6 +1236,46 @@ module.exports = grammar({
12401236
token.immediate(/"[cdw]?/),
12411237
),
12421238

1239+
// interpolated strings
1240+
interpolation_expression: ($) => seq("$(", $.expression, ")"),
1241+
1242+
interpolated_raw_string: ($) =>
1243+
seq(
1244+
"i`",
1245+
repeat(choice(/[^`$]+/, /\$[^(`]/, $.interpolation_expression)),
1246+
choice("`", "$`"), // tailing "$" special
1247+
),
1248+
1249+
interpolated_escape: ($) => "\\$",
1250+
1251+
interpolated_quoted_string: ($) =>
1252+
seq(
1253+
'i"',
1254+
repeat(
1255+
choice(
1256+
/[^"$\\]+/,
1257+
/\$[^(]/,
1258+
$.escape_sequence,
1259+
$.interpolated_escape,
1260+
$.interpolation_expression,
1261+
),
1262+
),
1263+
choice('"', '$"'), // tailing "$" special
1264+
),
1265+
1266+
interpolated_token_string: ($) =>
1267+
seq("iq{", optional($._i_token_string_tokens), "}"),
1268+
1269+
// we aren't tokenizing this yet
1270+
_i_token_string_tokens: ($) =>
1271+
repeat1(choice($._token_string_token, $.interpolation_expression)),
1272+
1273+
_i_token_string_token: ($) =>
1274+
choice(
1275+
seq("{", optional($._i_token_string_tokens), "}"),
1276+
choice($._token_no_braces, $.interpolation_expression),
1277+
),
1278+
12431279
// string literal stuff
12441280
string_literal: ($) =>
12451281
choice(
@@ -1248,6 +1284,9 @@ module.exports = grammar({
12481284
$.hex_string,
12491285
$.quoted_string,
12501286
$.token_string,
1287+
$.interpolated_raw_string,
1288+
$.interpolated_quoted_string,
1289+
$.interpolated_token_string,
12511290
),
12521291

12531292
char_literal: ($) => choice(/'[^\\']'/, seq("'", $.escape_sequence, "'")),

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "tree-sitter-d"
77
description = "D grammar for tree-sitter"
8-
version = "0.5.1"
8+
version = "0.6.0"
99
keywords = ["incremental", "parsing", "tree-sitter", "d"]
1010
classifiers = [
1111
"Intended Audience :: Developers",

src/grammar.json

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

0 commit comments

Comments
 (0)