Skip to content

Commit

Permalink
Add explicit support for tree sitter style markup so that we can use …
Browse files Browse the repository at this point in the history
…that for literate programming / multi 'file' files for examples etc.
  • Loading branch information
Cypher1 committed Oct 1, 2024
1 parent 6f3bbf8 commit 1ff50df
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tree-sitter-tako/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ module.exports = grammar({
extras: ($) => [$.nesting_comment, $.single_line_comment, "\r", "\n", "\t", " "],
rules: {
// TODO: add the actual grammar rules
source_file: ($) => seq(optional($.shebang), optional($._non_empty_body)),
source_file: ($) => seq(optional($.shebang), separated_one(optional($._non_empty_body), $.heading)),
_non_empty_body: ($) => separated_one($._statement, ';'),
_statement: ($) => choice(
$.block,
Expand Down Expand Up @@ -146,6 +146,7 @@ module.exports = grammar({
// TODO: Add semver.
shebang: (_) => seq('#!', /[^\n\r]*/),
single_line_comment: (_) => seq('//', /.*/),
heading: (_) => /====*[^='"]*====*/,
...operators_gen(),
}
});
1 change: 1 addition & 0 deletions tree-sitter-tako/playground.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tree-sitter generate && tree-sitter build --wasm && tree-sitter playground
41 changes: 37 additions & 4 deletions tree-sitter-tako/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-tako/src/node-types.json

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

0 comments on commit 1ff50df

Please sign in to comment.