// Generated by tools/grammars/update.sh. Do not edit.
//
// The equivalent of bindings/rust/lib.rs of tree-sitter/tree-sitter-regex v1.0.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_cache : Ref[@treesitter.Language?] = Ref(None)

///|
/// The tree-sitter language for the regex grammar (`LANGUAGE` in the Rust
/// binding), generated from `src/grammar.json`.
pub fn language() -> @treesitter.Language {
  load(language_cache, language_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 = @treesitter.Language::new(raw)
  cache.val = Some(language)
  language
}