https://github.com/hasundue/cycad
A helper module for using Tree-sitter in Deno
https://github.com/hasundue/cycad
deno tree-sitter
Last synced: about 2 months ago
JSON representation
A helper module for using Tree-sitter in Deno
- Host: GitHub
- URL: https://github.com/hasundue/cycad
- Owner: hasundue
- License: mit
- Created: 2023-10-18T04:30:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-22T04:30:20.000Z (over 2 years ago)
- Last Synced: 2025-06-11T08:47:00.912Z (about 1 year ago)
- Topics: deno, tree-sitter
- Language: TypeScript
- Homepage: https://deno.land/x/cycad
- Size: 104 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# 🌴 Cycad
> **Warning**\
> This project is still in early development. The API may change at any time.
Cycad is a helper module for using [Tree-sitter][tree-sitter] in [Deno][deno].
## Requirements
- [Deno][deno]
- [Tree-sitter][tree-sitter] (optional, Cycad may fetch a binary automatically)
- [Emscripten][emscripten] (optional, Tree-sitter may fetch a container
automatically)
## Usage
```typescript
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:
```typescript
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());
```
[tree-sitter]: https://tree-sitter.github.io/tree-sitter/
[deno]: https://deno.land/manual/getting_started/installation
[emscripten]: https://emscripten.org/docs/getting_started/downloads.html