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] Detach shebang from comment #32

Merged
merged 2 commits into from
Mar 16, 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
4 changes: 3 additions & 1 deletion tree_sitter_v/grammar.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ module.exports = grammar({
rules: {
source_file: ($) =>
seq(
optional($.shebang),
optional($.module_clause),
optional($.import_list),
repeat(
Expand All @@ -162,14 +163,15 @@ module.exports = grammar({
),
),

shebang: (_) => token(/\#\!([^\\\r\n]+)+/),

// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
comment: (_) =>
token(
choice(
/\/\/[^\n\r]*/,
/\/\*(?:[^\/][^\*]+\/\*+[^\/][^\*]+)+(?:[^\*][^\/]+\*+\/[^\*][^\/]+)+\//,
/\/\*[^\*]*\*\//,
/\#\!.*/,
),
),

Expand Down
2 changes: 2 additions & 0 deletions tree_sitter_v/node_types.v
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ pub enum NodeType {
nil_
none_
rune_literal
shebang
true_
}

Expand Down Expand Up @@ -491,5 +492,6 @@ const node_type_name_to_enum = {
'nil': NodeType.nil_
'none': NodeType.none_
'rune_literal': NodeType.rune_literal
'shebang': NodeType.shebang
'true': NodeType.true_
}
5 changes: 4 additions & 1 deletion tree_sitter_v/queries/helix.highlights.scm
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
(comment) @comment
[
(comment)
(shebang)
] @comment

(module_clause
(identifier) @namespace)
Expand Down
6 changes: 5 additions & 1 deletion tree_sitter_v/queries/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
(ERROR) @error
(comment) @comment

[
(comment)
(shebang)
] @comment

(identifier) @variable
(import_path) @variable
Expand Down
23 changes: 19 additions & 4 deletions tree_sitter_v/src/grammar.json

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

8 changes: 8 additions & 0 deletions tree_sitter_v/src/node-types.json

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

Loading