racket-tree-sitter (original) (raw)
8.15
1 Guide🔗ℹ
(require racket-tree-sitter ffi/unsafe ffi/unsafe/define) (define-ffi-definer define-racket (ffi-lib "./zig-out/lib/libtree-sitter-racket" '(#f))) (define-racket rkt-language (fun -> _TSLanguageRef) #:c-id tree_sitter_racket) (define p (parser-new)) (set-language p (rkt-language)) (define source-code "\n(+ 1 2)\n(define x 1)\n(define (foo a b)\n (+ a b x))\n") (define tree (parse-string p #f source-code)) (define root (root-node tree)) (displayln (node->string root)) (tree-delete tree)
2 Reference🔗ℹ
_TSParserRef : ctype? _TSLanguageRef : ctype? _TSTreeRef : ctype?
Tree sitter primitive types.
check a value is TSParserRef or not
check a value is TSLanguageRef or not
check a value is TSTreeRef or not
(parser-new) → TSParserRef?
New parser
(parser-delete parser) → void? parser : TSParserRef?
Delete a parser
(set-language parser language) → void? parser : TSParserRef? language : TSLanguageRef?
Setting the language of parser
(parse-string parser old-tree source-code) → TSTreeRef? parser : TSParserRef? old-tree : (or/c #f TSTreeRef?) source-code : string?
Parser a string source code