package tree-sitter

  1. Overview
  2. Docs
OCaml bindings for Tree-sitter

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mosaic-0.1.0.tbz
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9

doc/tree-sitter/Tree_sitter/Language/index.html

Module Tree_sitter.LanguageSource

Language grammars.

A Language.t describes the grammar rules, symbols, and fields for a particular programming language. Obtain one from a grammar package (e.g. Tree_sitter_json.language ()) rather than calling of_address directly.

Sourcetype t

The type for Tree-sitter language grammars.

Constructors

Sourceval of_address : nativeint -> t

of_address addr is a language from a native pointer addr.

Warning. addr must point to a valid TSLanguage returned by a tree_sitter_<lang>() C function. Prefer grammar-package helpers (e.g. Tree_sitter_json.language ()) instead.

Properties

Sourceval name : t -> string

name lang is the language name (e.g. "json", "ocaml").

Sourceval version : t -> int

version lang is the ABI version of the grammar.

Sourceval symbol_count : t -> int

symbol_count lang is the total number of symbols in the grammar.

Sourceval field_count : t -> int

field_count lang is the number of named fields in the grammar.

Symbol lookups

Sourceval symbol_name : t -> int -> string

symbol_name lang id is the name of symbol id.

Sourceval symbol_type : t -> int -> symbol_type

symbol_type lang id is the symbol_type of symbol id.

Sourceval symbol_for_name : t -> string -> named:bool -> int option

symbol_for_name lang name ~named is the symbol ID for name, if any. When ~named is true, only named (non-anonymous) symbols are searched.

Field lookups

Sourceval field_name_for_id : t -> int -> string option

field_name_for_id lang id is the field name for id, if any.

Sourceval field_id_for_name : t -> string -> int option

field_id_for_name lang name is the field ID for name, if any.