Module TreeSitterFrontend.TreeSitterFFI

FFI bindings to the bundled tree-sitter runtime and C grammar. Parses C source files directly without shelling out to the tree-sitter CLI.

type cst_node = {
  1. tag : string;
    (*

    node type, e.g. "function_definition", "identifier"

    *)
  2. field : string option;
    (*

    field name in parent, e.g. "type", "declarator", "body"

    *)
  3. srow : int;
  4. scol : int;
  5. erow : int;
  6. ecol : int;
  7. text : string;
    (*

    text content for leaf nodes

    *)
  8. children : cst_node list;
}

Tree-sitter CST node, matching the structure produced by both the XML parser and the C FFI.

val parse_file : string -> cst_node

Parse a C source file and return the root CST node (translation_unit).

val pp_cst_node : Stdlib.Format.formatter -> ?indent:int -> cst_node -> unit

Pretty-print a CST node tree in S-expression style for debugging.