Metadata-Version: 2.1
Name: tree-sitter-ocaml
Version: 0.24.2
Summary: OCaml grammar for tree-sitter
License: MIT
Project-URL: Homepage, https://github.com/tree-sitter/tree-sitter-ocaml
Keywords: incremental,parsing,tree-sitter,ocaml
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Software Development :: Compilers
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: core
Requires-Dist: tree-sitter~=0.24; extra == "core"

# tree-sitter-ocaml

[![CI][ci]](https://github.com/tree-sitter/tree-sitter-ocaml/actions/workflows/ci.yml)
[![pypi][pypi]](https://pypi.org/project/tree-sitter-ocaml/)

This module provides OCaml grammars for the [tree-sitter][] parsing library.
There are separate grammars for implementations (`.ml`), interfaces (`.mli`)
and types.

## Installation

```sh
pip install tree-sitter-ocaml
```

You will probably also need the [tree-sitter binding][tree-sitter binding].

```sh
pip install tree-sitter
```

## Usage

Load the grammar as a `Language` object:

```python
import tree_sitter_ocaml
from tree_sitter import Language, Parser

language_ocaml = Language(tree_sitter_ocaml.language_ocaml())
```

Create a `Parser` and configure it to use the language:

```python
parser = Parser(language_ocaml)
```

Parse some source code:

```python
tree = parser.parse(
    b"""
    module M : sig
      val x : int
    end
    """
)
```

Use `language_ocaml_interface()` to parse interface files (with `.mli` extension)
and `language_ocaml_type()` to parse type signatures.

[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/tree-sitter-ocaml/ci.yml?logo=github&label=CI
[pypi]: https://img.shields.io/pypi/v/tree-sitter-ocaml?logo=pypi&logoColor=white&label=PyPI
[tree-sitter]: https://tree-sitter.github.io/tree-sitter/
[tree-sitter binding]: https://pypi.org/project/tree-sitter/
