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

[tree_sitter_v] fix issuse bug #42

Merged
merged 9 commits into from
Mar 23, 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
124 changes: 64 additions & 60 deletions tree_sitter_v/grammar.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -578,17 +578,7 @@ module.exports = grammar({
prec.dynamic(2, seq(token.immediate("["), comma_sep1($.plain_type), "]")),

argument_list: ($) =>
seq(
"(",
optional(
seq(
choice($.argument),
repeat(seq(list_separator, choice($.argument))),
optional(list_separator),
),
),
")",
),
seq("(", repeat(seq($.argument, optional(list_separator))), ")"),

argument: ($) =>
choice(
Expand Down Expand Up @@ -1032,76 +1022,90 @@ module.exports = grammar({
),

c_string_literal: ($) =>
choice(
seq(
$.__c_single_quote,
repeat(
choice(
token.immediate(prec(1, /[^'\\$]+/)),
$.escape_sequence,
$.string_interpolation,
prec(
1,
choice(
seq(
$.__c_single_quote,
repeat(
choice(
token.immediate(prec.right(1, /[^'\\$]+/)),
$.escape_sequence,
$.string_interpolation,
),
),
$.__single_quote,
),
$.__single_quote,
),
seq(
$.__c_double_quote,
repeat(
choice(
token.immediate(prec(1, /[^"\\$]+/)),
$.escape_sequence,
$.string_interpolation,
seq(
$.__c_double_quote,
repeat(
choice(
token.immediate(prec.right(1, /[^"\\$]+/)),
$.escape_sequence,
$.string_interpolation,
),
),
$.__double_quote,
),
$.__double_quote,
),
),

raw_string_literal: ($) =>
choice(
seq(
$.__r_single_quote,
repeat(token.immediate(prec(1, /[^'\\]+/))),
$.__single_quote,
),
seq(
$.__r_double_quote,
repeat(token.immediate(prec(1, /[^"\\]+/))),
$.__double_quote,
prec(
1,
choice(
seq(
$.__r_single_quote,
repeat(token.immediate(prec.right(1, /[^'\\]+/))),
$.__single_quote,
),
seq(
$.__r_double_quote,
repeat(token.immediate(prec.right(1, /[^"\\]+/))),
$.__double_quote,
),
),
),

interpreted_string_literal: ($) =>
choice(
seq(
$.__single_quote,
repeat(
choice(
token.immediate(prec(1, /[^'\\$]+/)),
$.escape_sequence,
$.string_interpolation,
prec(
1,
choice(
seq(
$.__single_quote,
repeat(
choice(
token.immediate(prec.right(1, /[^'\\$]+/)),
$.escape_sequence,
$.string_interpolation,
),
),
$.__single_quote,
),
$.__single_quote,
),
seq(
$.__double_quote,
repeat(
choice(
token.immediate(prec(1, /[^"\\$]+/)),
$.escape_sequence,
$.string_interpolation,
seq(
$.__double_quote,
repeat(
choice(
token.immediate(prec.right(1, /[^"\\$]+/)),
$.escape_sequence,
$.string_interpolation,
),
),
$.__double_quote,
),
$.__double_quote,
),
),

string_interpolation: ($) =>
seq(
alias($.__dolcbr, $.interpolation_opening),
alias($._expression, $.interpolation_expression),
optional($.format_specifier),
choice(
repeat(alias($._expression, $.interpolation_expression)),
seq(
alias($._expression, $.interpolation_expression),
$.format_specifier,
),
),
alias($.__rcbr, $.interpolation_closing),
),

Expand All @@ -1120,7 +1124,7 @@ module.exports = grammar({
),

pseudo_compile_time_identifier: ($) =>
seq("@", alias(/[A-Z][A-Z0-9_]+/, $.identifier)),
token(seq("@", alias(token.immediate(/[A-Z][A-Z0-9_]+/), $.identifier))),

identifier: () =>
token(
Expand Down
6 changes: 3 additions & 3 deletions tree_sitter_v/node_types.v
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ pub enum NodeType {
parenthesized_expression
plain_type
pointer_type
pseudo_compile_time_identifier
qualified_type
range
range_clause
Expand Down Expand Up @@ -181,6 +180,7 @@ pub enum NodeType {
interpolation_opening
nil_
none_
pseudo_compile_time_identifier
rune_literal
shebang
true_
Expand Down Expand Up @@ -288,8 +288,8 @@ const declaration_node_types = [

const identifier_node_types = [
NodeType.mutable_identifier,
.pseudo_compile_time_identifier,
.identifier,
.pseudo_compile_time_identifier,
]

const literal_node_types = [
Expand Down Expand Up @@ -432,7 +432,6 @@ const node_type_name_to_enum = {
'parenthesized_expression': NodeType.parenthesized_expression
'plain_type': NodeType.plain_type
'pointer_type': NodeType.pointer_type
'pseudo_compile_time_identifier': NodeType.pseudo_compile_time_identifier
'qualified_type': NodeType.qualified_type
'range': NodeType.range
'range_clause': NodeType.range_clause
Expand Down Expand Up @@ -491,6 +490,7 @@ const node_type_name_to_enum = {
'interpolation_opening': NodeType.interpolation_opening
'nil': NodeType.nil_
'none': NodeType.none_
'pseudo_compile_time_identifier': NodeType.pseudo_compile_time_identifier
'rune_literal': NodeType.rune_literal
'shebang': NodeType.shebang
'true': NodeType.true_
Expand Down
Loading