normalize_facts/parsers.rs
1//! Tree-sitter parser convenience re-exports.
2//!
3//! Delegates entirely to [`normalize_languages::parsers`] — the canonical
4//! singleton lives there. This module exists so that call sites inside
5//! `normalize-facts` can write `crate::parsers::parse_with_grammar` without
6//! importing from a sibling crate explicitly.
7//!
8//! # Lifetime safety
9//!
10//! The `GrammarLoader` is stored in a `'static OnceLock` inside
11//! `normalize_languages::parsers`, so it outlives any `Tree` produced here.
12//! Trees must be dropped before the end of the extraction call that created
13//! them; they must not be stored in long-lived structs.
14
15use std::sync::Arc;
16
17pub use normalize_languages::parsers::{
18 MissingGrammar, available_external_grammars, parse_with_grammar, parser_for,
19 peek_missing_grammars, report_missing_grammar, take_missing_grammars, try_get_grammar,
20};
21
22/// Get the global grammar loader singleton (canonical instance from `normalize-languages`).
23pub fn grammar_loader() -> Arc<normalize_languages::GrammarLoader> {
24 normalize_languages::parsers::grammar_loader()
25}