// Generated by tools/grammars/update.sh. Do not edit.
//
// The equivalent of bindings/rust/lib.rs of tree-sitter/tree-sitter-ocaml v0.26.0:
// the languages of the grammar (`LanguageFn` constants there) as functions
// returning a `@treesitter.Language`, decoded on first use; the string
// constants (queries, node types) are in the other files of the package.
///|
let language_ocaml_cache : Ref[@treesitter.Language?] = Ref(None)
///|
/// The tree-sitter language for `ocaml` (`LANGUAGE_OCAML` in the Rust binding),
/// generated from `grammars/ocaml/src/grammar.json`. Its external scanner is
/// `@scanners.scanner_for("ocaml")`; without one (a scanner not ported yet) the
/// language is not parseable (`@treesitter.Language::is_parseable`).
pub fn language_ocaml() -> @treesitter.Language {
load(language_ocaml_cache, language_ocaml_tables)
}
///|
let language_ocaml_interface_cache : Ref[@treesitter.Language?] = Ref(None)
///|
/// The tree-sitter language for `ocaml_interface` (`LANGUAGE_OCAML_INTERFACE`
/// in the Rust binding), generated from `grammars/interface/src/grammar.json`.
/// Its external scanner is `@scanners.scanner_for("ocaml_interface")`; without
/// one (a scanner not ported yet) the language is not parseable
/// (`@treesitter.Language::is_parseable`).
pub fn language_ocaml_interface() -> @treesitter.Language {
load(language_ocaml_interface_cache, language_ocaml_interface_tables)
}
///|
let language_ocaml_type_cache : Ref[@treesitter.Language?] = Ref(None)
///|
/// The tree-sitter language for `ocaml_type` (`LANGUAGE_OCAML_TYPE` in the Rust
/// binding), generated from `grammars/type/src/grammar.json`. Its external
/// scanner is `@scanners.scanner_for("ocaml_type")`; without one (a scanner not
/// ported yet) the language is not parseable
/// (`@treesitter.Language::is_parseable`).
pub fn language_ocaml_type() -> @treesitter.Language {
load(language_ocaml_type_cache, language_ocaml_type_tables)
}
///|
fn load(
cache : Ref[@treesitter.Language?],
tables : String,
) -> @treesitter.Language {
if cache.val is Some(language) {
return language
}
let raw = @language.Language::from_compact_base64(tables) catch {
e => abort(e.to_string())
}
let language = if raw.external_token_count > 0 {
@treesitter.Language::new(
raw,
external_scanner?=@scanners.scanner_for(raw.name),
)
} else {
@treesitter.Language::new(raw)
}
cache.val = Some(language)
language
}