Crate tree_sitter_ocaml

Source
Expand description

This crate provides OCaml language support for the tree-sitter parsing library. There are separate languages for implementation, (.ml), interfaces (.mli) and types.

Typically, you will use LANGUAGE_OCAML to add this language to a tree-sitter Parser, and then use the parser to parse some code:

let code = r#"
  module M = struct
    let x = 0
  end
"#;
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_ocaml::LANGUAGE_OCAML;
parser
    .set_language(&language.into())
    .expect("Error loading OCaml language");
let tree = parser.parse(code, None).unwrap();
assert!(!tree.root_node().has_error());

Use LANGUAGE_OCAML_INTERFACE to parse interface files (with .mli extension) and LANGUAGE_OCAML_TYPE to parse type signatures.

Constantsยง

HIGHLIGHTS_QUERY
The syntax highlighting query for OCaml.
INTERFACE_NODE_TYPES
The content of the node-types.json file for OCaml interfaces.
LANGUAGE_OCAML
The tree-sitter LanguageFn for OCaml.
LANGUAGE_OCAML_INTERFACE
The tree-sitter LanguageFn for OCaml interfaces.
LANGUAGE_OCAML_TYPE
The tree-sitter LanguageFn for OCaml types.
LOCALS_QUERY
The local-variable syntax highlighting query for OCaml.
OCAML_NODE_TYPES
The content of the node-types.json file for OCaml.
TAGS_QUERY
The symbol tagging query for OCaml.
TYPE_NODE_TYPES
The content of the node-types.json file for OCaml types.