Warning
This project is still in early development. The API may change at any time.
Cycad is a helper module for using Tree-sitter in Deno.
- Deno
- Tree-sitter (optional, Cycad may fetch a binary automatically)
- Emscripten (optional, Tree-sitter may fetch a container automatically)
import { Parser } from "https://deno.land/x/cycad@{VERSION}/mod.ts";
// Parser for TypeScript will be fetched and compiled automatically!
// It may take a while for the first run.
const parser = await Parser.create("typescript");
const tree = parser.parse("const x = 1;");
console.log(tree.rootNode.toString());
Or, you may import the parser directly without async code:
import { parser } from "https://deno.land/x/cycad@{VERSION}/parser.ts?lang=typescript";
const tree = parser.parse("const x = 1;");
console.log(tree.rootNode.toString());