Skip to main content

OCaml grammar for tree-sitter

Project description

tree-sitter-ocaml

CI pypi

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

Installation

pip install tree-sitter-ocaml

You will probably also need the tree-sitter binding.

pip install tree-sitter

Usage

Load the grammar as a Language object:

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:

parser = Parser(language_ocaml)

Parse some source code:

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_sitter_ocaml-0.23.1.tar.gz (3.7 MB view hashes)

Uploaded Source

Built Distributions

tree_sitter_ocaml-0.23.1-cp39-abi3-win_arm64.whl (1.4 MB view hashes)

Uploaded CPython 3.9+ Windows ARM64

tree_sitter_ocaml-0.23.1-cp39-abi3-win_amd64.whl (1.4 MB view hashes)

Uploaded CPython 3.9+ Windows x86-64

tree_sitter_ocaml-0.23.1-cp39-abi3-musllinux_1_2_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.9+ musllinux: musl 1.2+ x86-64

tree_sitter_ocaml-0.23.1-cp39-abi3-musllinux_1_2_aarch64.whl (1.5 MB view hashes)

Uploaded CPython 3.9+ musllinux: musl 1.2+ ARM64

tree_sitter_ocaml-0.23.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.9+ manylinux: glibc 2.17+ x86-64

tree_sitter_ocaml-0.23.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.6 MB view hashes)

Uploaded CPython 3.9+ manylinux: glibc 2.17+ ARM64

tree_sitter_ocaml-0.23.1-cp39-abi3-macosx_11_0_arm64.whl (1.5 MB view hashes)

Uploaded CPython 3.9+ macOS 11.0+ ARM64

tree_sitter_ocaml-0.23.1-cp39-abi3-macosx_10_9_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.9+ macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page