Coverage report: /home/ellis/comp/core/lib/syn/ts.lisp
Kind | Covered | All | % |
expression | 15 | 53 | 28.3 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; ts.lisp --- Tree-sitter API
3
;; High-level Tree-sitter API
7
;; Tree-sitter is currently the most well-supported syntax parsing backend in
8
;; use by IDEs, and we can generally rely on the various language grammars
9
;; defined via tree-sitter. As we progress we may adapt other more direct
10
;; methods of building ASTs by querying compilers directly, but for now we
11
;; have some catching up to do :).
16
(load-tree-sitter-alien)
18
;; (setq syn/lang:*language* :rust)
19
(defmacro with-lang (lang &body body)
20
`(with-ts-lang syn/lang:*language* ,lang
23
(defun lang-stats (lang)
25
(cons (ts-language-symbol-count l)
26
(ts-language-field-count l))))
28
(defun parse-file (lang path &key (produce-cst t) (consume t) (start 0) (end))
31
(with-output-to-string (s)
32
(write-file-into-stream path s))
34
:produce-cst produce-cst
38
(defun ts-file-query (lang path query)
39
(let ((input (with-output-to-string (s) (write-file-into-stream path s))))
40
(with-ts-query (q lang query (length query))
41
(with-ts-query-cursor c
42
(let ((tree (parse-string lang input :consume nil)))
43
(tree-sitter::ts-query-cursor-exec-pointer c q (tree-sitter::ts-tree-root-node-pointer tree))