Mercurial > core / lisp/ffi/tree-sitter/ffi.lisp
changeset 523: |
04d0a4f857f6 |
parent: |
48e671eac752
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Sun, 07 Jul 2024 20:10:49 -0400 |
permissions: |
-rw-r--r-- |
description: |
tree-sitter ffi fixes |
1 ;;; ffi/tree-sitter/ffi.lisp --- Low-level FFI bindings for Tree-sitter 5 ;; see https://github.com/death/cl-tree-sitter for an alternative 6 ;; implementation - has functions for working on pointers instead of 7 ;; raw objects like below: 9 ;;(define-alien-routine ts-node-start-point-pointer ts-point (self (* ts-node))) 10 ;;(define-alien-routine ts-node-end-point-pointer ts-point (self (* ts-node))) 13 (in-package :tree-sitter) 16 (define-alien-type ts-state-id unsigned-int) 17 (define-alien-type ts-symbol unsigned-int) 18 (define-alien-type ts-field-id unsigned-int) 19 (define-alien-type ts-language (struct ts-language)) 20 (define-alien-type ts-parser (struct ts-parser)) 21 (define-alien-type ts-tree (struct ts-tree)) 23 (define-alien-type ts-query (struct ts-query)) 24 (define-alien-type ts-query-error unsigned-int) 25 (define-alien-type ts-query-cursor (struct ts-query-cursor)) 26 (define-alien-type ts-lookahead-iterator (struct ts-lookahead-iterator)) 27 (define-alien-type ts-point 30 (column unsigned-int))) 31 (define-alien-type ts-range 33 (start-point ts-point) 35 (start-byte unsigned-int) 36 (end-byte unsigned-int))) 38 (define-alien-enum (ts-log-type int) 42 (define-alien-type ts-logger 45 (log (* (function void (* t) ts-log-type c-string))))) 47 (define-alien-type ts-input-edit 49 (start-byte unsigned-int) 50 (old-end-byte unsigned-int) 51 (new-end-byte unsigned-int) 52 (start-point ts-point) 53 (old-end-point ts-point) 54 (new-end-point ts-point))) 56 (define-alien-type ts-node 58 (context (array unsigned-int 4)) 62 (define-alien-type ts-tree-cursor 66 (context (array unsigned-int 2)))) 68 (define-alien-enum (ts-input-encoding int) 72 (define-alien-enum (ts-symbol-type int) 77 (define-alien-type ts-input (struct ts-input 79 (read (* (function c-string (* t) 83 (encoding ts-input-encoding))) 86 (define-alien-routine ts-parser-new (* ts-parser)) 87 (define-alien-routine ts-parser-delete void (self (* ts-parser))) 88 (define-alien-routine ts-parser-reset void (self (* ts-parser))) 89 (define-alien-routine ts-parser-set-language boolean (self (* ts-parser)) (language (* ts-language))) 90 (define-alien-routine ts-parser-language (* ts-language) (self (* ts-parser))) 91 ;; (define-alien-routine ts-parser-parse (* ts-tree) (self (* ts-parser)) (old-tree (* ts-tree)) (input ts-input)) 92 (define-alien-routine ts-parser-parse-string (* ts-tree) (self (* ts-parser)) (old-tree (* ts-tree)) (string c-string) (length unsigned-int)) 93 ;; Set the file descriptor to which the parser should write debugging graphs 94 ;; during parsing. The graphs are formatted in the DOT language. You may want 95 ;; to pipe these graphs directly to a `dot(1)` process in order to generate 96 ;; SVG output. You can turn off this logging by passing a negative number. 97 (define-alien-routine ts-parser-print-dot-graphs void (self (* ts-parser)) (fd int)) 99 (define-alien-routine ts-tree-copy (* ts-tree) (self (* ts-tree))) 100 (define-alien-routine ts-tree-delete void (self (* ts-tree))) 101 (define-alien-routine ts-tree-language (* ts-language) (self (* ts-tree))) 102 (define-alien-routine ts-tree-edit void (self (* ts-tree)) (edit (* unsigned-int))) 103 (define-alien-routine ts-tree-print-dot-graph void (self (* ts-tree)) (file-descriptor int)) 106 (define-alien-routine ts-tree-cursor-current-field-name c-string (cursor (* ts-tree-cursor))) 108 (define-alien-routine ts-tree-cursor-goto-next-sibling boolean (self (* ts-tree-cursor))) 110 (define-alien-routine ts-tree-cursor-goto-parent boolean (self (* ts-tree-cursor))) 112 (define-alien-routine ts-tree-cursor-goto-first-child boolean (self (* ts-tree-cursor))) 114 (define-alien-routine ts-tree-cursor-delete void (cursor (* ts-tree-cursor))) 116 (define-alien-routine ts-language-version unsigned-int (v (* ts-language))) 117 (define-alien-routine ts-language-symbol-count unsigned-int (v (* ts-language))) 118 (define-alien-routine ts-language-symbol-name c-string (v (* ts-language)) (s (* ts-symbol))) 119 (define-alien-routine ts-language-field-count unsigned-int (v (* ts-language))) 122 (define-alien-routine ts-query-new (* ts-query) 123 (lang (* ts-language)) 125 (source-len unsigned-int) 126 (error-offset (* unsigned-int)) 127 (error-type (* ts-query-error))) 129 (define-alien-routine ts-query-delete void (query (* ts-query))) 132 (define-alien-routine ts-tree-root-node-pointer (* ts-node) 135 (define-alien-routine ts-tree-cursor-new-pointer (* ts-tree-cursor) 138 (define-alien-routine ts-node-is-named-pointer boolean 141 (define-alien-routine ts-tree-cursor-current-node-pointer (* ts-node) 142 (cursor (* ts-tree-cursor))) 144 (define-alien-routine ts-node-start-point-pointer (* ts-point) 147 (define-alien-routine ts-node-end-point-pointer (* ts-point) 150 (define-alien-routine ts-node-type-pointer c-string