JSON grammar for tree-sitter (tree-sitter/tree-sitter-json v0.24.8), for the MoonBit port of Tree-sitter (moonbit-community/treesitter).
| MoonBit | Rust |
|---|---|
| language() -> @treesitter.Language | LANGUAGE |
| node_types : String | NODE_TYPES (src/node-types.json) |
| highlights_query : String | HIGHLIGHTS_QUERY (queries/highlights.scm) |
moon add moonbit-community/tree-sitter-jsonimport {
"moonbit-community/treesitter",
"moonbit-community/tree-sitter-json" @tree_sitter_json,
}///|
test "parse json" {
let language = @tree_sitter_json.language()
let parser = @treesitter.Parser::new()
parser.set_language(language)
let source =
#|[
#| 345,
#| 10.1,
#| 10,
#| -10,
#| null,
#| true,
#| false,
#| { "stuff": "good" }
#|]
#|
guard parser.parse(@utf8.encode(source)) is Some(tree) else {
fail("parse failed")
}
let root = tree.root_node()
assert_false(root.has_error())
assert_false(root.to_sexp().contains("ERROR"))
}let highlights_query : Stringlet node_types : StringInstall
Download zipJSON grammar for tree-sitter (tree-sitter/tree-sitter-json v0.24.8), for the MoonBit port of Tree-sitter (moonbit-community/treesitter).