Skip to main content

big_code_analysis_ast/
lang_helpers.rs

1//! Byte-level identity helpers shared by the classifiers and the metrics.
2//!
3//! Some questions a walk asks are not answerable from a node's kind: an
4//! Elixir `def` and a `quote` are both `Call` nodes told apart only by
5//! their target text, a Tcl `switch` is a plain `command` whose leading
6//! word names the builtin, and Python's aliased `block` / `lambda` kinds
7//! must be normalised at one site (grammar-dispatch §9 and §10). These
8//! helpers read the bytes once so `Checker`, `Getter`, and every metric
9//! agree on the answer.
10//!
11//! They live beside the classifiers rather than in a metric module
12//! because the classifiers consult them: a `Checker` impl that imported
13//! a helper *from* `metrics::cognitive` would make the parse layer depend
14//! on the metric layer, the inversion #1376 exists to remove.
15
16pub mod bash;
17pub mod elixir;
18// Crate-private: this dialect's only helper is a kind table the three
19// classifiers in this crate share, and nothing outside names it.
20pub(crate) mod irules;
21pub mod perl;
22pub mod python;
23pub mod tcl;
24// Crate-private for the same reason as `irules` above: the braced-word
25// slot rule is read by this crate's three classifiers and by nothing
26// outside it. The one exception is re-exported below rather than by
27// widening the module, which would publish the slot tables too.
28pub(crate) mod tcl_family;
29
30/// Re-exported because both dialects' metrics need it and the module
31/// holding it is crate-private: iRules' nexits and ABC walkers resolve a
32/// leading word themselves rather than through `tcl::tcl_command_name`,
33/// so they normalise the `::` qualifier at their own call sites.
34pub use tcl_family::strip_global_qualifier;