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.ocaml/Tree_sitter_ocaml/index.html

Module Tree_sitter_ocamlSource

Tree-sitter OCaml grammars with built-in highlighting.

This module provides grammars for three OCaml dialects — implementation files (.ml), interface files (.mli), and standalone type expressions — together with convenience highlighting functions.

  let ranges = Tree_sitter_ocaml.highlight_ocaml "let x = 1"
  (* ranges : (int * int * string) list *)

Languages

Sourceval ocaml : unit -> Tree_sitter.Language.t

ocaml () is the grammar for OCaml implementation files (.ml).

Sourceval interface : unit -> Tree_sitter.Language.t

interface () is the grammar for OCaml interface files (.mli).

Sourceval type_ : unit -> Tree_sitter.Language.t

type_ () is the grammar for standalone OCaml type expressions.

Highlighting

Sourceval ocaml_highlights_query : string

ocaml_highlights_query is the highlight query source for OCaml implementation files. Targets comments, strings, types, keywords, variables, and numbers.

Sourceval interface_highlights_query : string

interface_highlights_query is the highlight query source for OCaml interface files. Currently identical to ocaml_highlights_query.

Sourceval highlight_ocaml : string -> (int * int * string) list

highlight_ocaml content parses content as OCaml and returns (start_byte, end_byte, capture_group) triples. Equivalent to parsing with ocaml and running Tree_sitter.highlight with ocaml_highlights_query.

Sourceval highlight_interface : string -> (int * int * string) list

highlight_interface content parses content as an OCaml interface and returns (start_byte, end_byte, capture_group) triples. Equivalent to parsing with interface and running Tree_sitter.highlight with interface_highlights_query.