Expand description
A shared language-parsing substrate for static-analysis tools:
tree-sitter grammar dispatch, language detection (registry), and a
growing set of language-agnostic analysis primitives — import/call
graphs, control-flow graphs, structural fingerprinting, suppression
comments — built on top of a unified registry::LanguageInfo table
across 16 languages, compiled in at build time via Cargo feature flags.
Consumers include knots, moldy, and aurora-lint; see this crate’s README
for the full module-to-purpose table.
Re-exports§
pub use c_standard::detect_min_c_standard;pub use c_standard::CStandard;pub use calls::call_edges;pub use calls::collect_local_names;pub use calls::get_function_name;pub use calls::is_function_kind;pub use calls::CallEdge;pub use cfg::build_function_cfg;pub use cfg::BasicBlock;pub use cfg::BlockId;pub use cfg::CfgEdge;pub use cfg::FunctionCfg;pub use classify::classify;pub use classify::classify_file;pub use classify::BinaryKind;pub use classify::ClassifyLimits;pub use classify::FileClass;pub use classify::SourceText;pub use classify::TextEncoding;pub use classify::DEFAULT_PREFIX_LEN;pub use cpp_header::looks_like_cpp;pub use cpp_header::sniff_header;pub use cpp_header::sniff_header_with_budget;pub use cpp_header::HeaderSniff;pub use dead_code::dead_code_ranges;pub use dead_code::dead_code_ranges_with_assumptions;pub use dead_code::posix_default_assumptions;pub use dead_code::DeadCodeReason;pub use dead_code::DeadCodeRegion;pub use dead_code::PlatformAssumptions;pub use dead_code_csharp::csharp_dead_code_regions;pub use dead_code_csharp::CSharpDeadCodeRegion;pub use dead_code_swift::swift_dead_code_regions;pub use dead_code_swift::SwiftDeadCodeRegion;pub use fingerprint::block_fingerprints;pub use fingerprint::duplicate_groups;pub use fingerprint::function_fingerprints;pub use fingerprint::is_block_kind;pub use fingerprint::structural_hash;pub use fingerprint::CorpusFingerprint;pub use fingerprint::Fingerprint;pub use fingerprint::FingerprintTier;pub use flat::flatten;pub use flat::FlatTree;pub use imports::distinct_import_count;pub use imports::import_sources;pub use isr::interrupt_handlers;pub use isr::InterruptEvidence;pub use isr::InterruptHandler;pub use parse_budget::parse_within_budget;pub use parse_budget::BudgetExceeded;pub use parse_budget::ParseBudget;pub use path_ignore::PathIgnore;pub use query::ancestors;pub use query::child_nodes;pub use query::find_ancestor;pub use query::find_ancestor_from_root;pub use query::find_descendants;pub use query::find_descendants_of_kind;pub use query::find_descendants_of_kinds;pub use query::find_first_descendant;pub use query::named_child_nodes;pub use query::nearest_ancestor_of_kind;pub use query::nearest_ancestor_of_kind_from_root;pub use query::nearest_ancestor_of_kinds;pub use query::nearest_ancestor_of_kinds_from_root;pub use query::node_text;pub use query::walk_preorder;pub use query::Walk;pub use regions::ignored_regions;pub use regions::IgnoredRegion;pub use registry::language_for_header_content;pub use registry::is_discoverable_file;pub use registry::is_extension_for_language;pub use registry::is_parseable_extension;pub use registry::is_source_extension;pub use registry::language_for_file;pub use registry::language_for_key;pub use registry::language_info_for_file;pub use registry::languages;pub use registry::sloc_mode_for_file;pub use registry::supported_languages_report;pub use registry::LanguageInfo;pub use registry::SlocMode;pub use suppressions::suppressions;pub use suppressions::Suppression;pub use tsquery::run_query;pub use tsquery::Capture;pub use tree_sitter_ada;pub use tree_sitter_c;pub use tree_sitter_c_sharp;pub use tree_sitter_cpp;pub use tree_sitter_fortran;pub use tree_sitter_go;pub use tree_sitter_java;pub use tree_sitter_javascript;pub use tree_sitter_kotlin_ng;pub use tree_sitter_lua;pub use tree_sitter_php;pub use tree_sitter_python;pub use tree_sitter_rust;pub use tree_sitter_scala;pub use tree_sitter_swift;pub use tree_sitter_typescript;
Modules§
- c_
standard - Best-effort lower bound on which C standard a file’s syntax requires.
- calls
- Call-graph edge extraction.
- cfg
- Language-agnostic control-flow graph / basic-block construction on top of
the tree-sitter parse — Tier 3 of the substrate’s capability model, after
parsing (Tier 1) and per-file import and call edges (Tier 2). Generalizes
the shape of aurora-lint’s C-only CFG builder
(
aurora-lint/src/analyze/cfg.rs) for shared use. - classify
- Cheap, heuristic file-type classification, so a consumer can exit early before handing a file to tree-sitter.
- cpp_
header - Best-effort content-based disambiguation for
.hfiles between C and C++. - dead_
code - Preprocessor dead-code region detection for C/C++.
- dead_
code_ csharp - Dead-code region detection for C#’s
#if/#elif/#else/#endifconditional compilation. - dead_
code_ swift - Dead-code region detection for Swift’s
#if/#elseif/#else/#endifconditional compilation. - fingerprint
- AST subtree fingerprinting — the primitive behind cross-corpus clone detection (Tier 5). Computes a structural hash per function-like subtree, ignoring identifier and literal text so that a function renamed or with different constants still hashes identically to its original (Type-2 clone detection, in the PMD-CPD/BlackDuck sense). Byte-for-byte (Type-1) matching falls out for free too, since identical text obviously has identical structure.
- flat
- A flat, index-linked snapshot of a whole tree-sitter tree.
- imports
- Syntactic import-source extraction.
- isr
- Interrupt-handler (ISR) detection for C/C++.
- parse_
budget - Parsing with a work budget, so a malformed input costs a bounded amount.
- path_
ignore - External-config path ignoring — glob patterns such as
toolchain.toml’s[ignore].paths(per-tool[<tool>.ignore]sections are proposed). - query
- Generic AST pattern-matching primitives shared across the substrate’s consumers — a thin “find nodes matching a predicate” query layer over tree-sitter, generalizing the ad hoc recursive search helpers that aurora-lint’s CERT-C rules once duplicated; they now import them from here.
- regions
- Inline
tools:off/tools:onregion scanning. - registry
- The language registry:
LANGUAGES’s runtime form (languages()), and every lookup consumers use to get from a file to a tree-sitterLanguage— by file name or extension (language_for_file), by sniffed.hcontent (language_for_header_content), or by registry key (language_for_key). Also the extension-classification predicates (is_source_extension,is_parseable_extension) that drive recursive file discovery in knots and moldy, andis_extension_for_language, which aurora-lint uses to discover C files only. - suppressions
- Inline
tools:suppress TOOL:RULEsingle-line suppression comments. - tsquery
- Run a tree-sitter query (S-expression pattern language) and return owned captures, plus each grammar’s bundled tags query.