Skip to content

Commit

Permalink
grammar: Doc comments back to normal
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Jul 3, 2024
1 parent 21267c7 commit d684ed7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ module.exports = grammar({
rules: {
source_file: $ => repeat(choice($.statement, $.doc_comment, $.comment)),

comment: _ => token(seq("#", /[^\#].*/)),
comment: _ => token(seq("#", /[^#].*/)),
doc_comment: $ => seq("##", $.doc_comment_content),
doc_comment_content: _ => /.*/,

// TODO This is a bit of a trick: https://github.com/tree-sitter/tree-sitter/discussions/1173
// Ideally, we'd use an external scanner to do this so we can make the closing delimiter optional.

// doc_comment: $ => seq("/*", $.doc_comment_content, "/"),
// doc_comment_content: _ => /[^*]*\*+([^/*][^*]*\*+)*/,

statement: $ =>
choice($.block, $.expression, $.print, $.assert, $.assignment, $.import, $.function_declaration, $.class_declaration),

Expand Down
4 changes: 3 additions & 1 deletion queries/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
; v. 1.0. Copyright (c) 2024 Aymeric Wibo

(doc_comment
(doc_comment_content) @injection.content (#set! injection.language "markdown")
(doc_comment_content) @injection.content
; TODO injection.language "markdown", once I've got my injection.common shit figured out.
(#set! injection.language "none")
)
2 changes: 1 addition & 1 deletion src/grammar.json

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

0 comments on commit d684ed7

Please sign in to comment.