Skip to main content

Module lang_helpers

Module lang_helpers 

Source
Expand description

Byte-level identity helpers shared by the classifiers and the metrics.

Some questions a walk asks are not answerable from a node’s kind: an Elixir def and a quote are both Call nodes told apart only by their target text, a Tcl switch is a plain command whose leading word names the builtin, and Python’s aliased block / lambda kinds must be normalised at one site (grammar-dispatch §9 and §10). These helpers read the bytes once so Checker, Getter, and every metric agree on the answer.

They live beside the classifiers rather than in a metric module because the classifiers consult them: a Checker impl that imported a helper from metrics::cognitive would make the parse layer depend on the metric layer, the inversion #1376 exists to remove.

Modules§

bash
Bash: the logical connectives and the string comparison of a [ … ] / [[ … ]] test.
elixir
Elixir: keyword Call identity (def, defmodule, quote, …), and applied versus named operators.
perl
Perl: telling the and and not operators, and the file tests, from an auto-quoted key that the grammar lexes as one of them.
python
Python: the aliased block and lambda kind sets.
tcl
Tcl: the leading word of a command node, and the grammar’s braced-word kind ids.

Functions§

strip_global_qualifier
Re-exported because both dialects’ metrics need it and the module holding it is crate-private: iRules’ nexits and ABC walkers resolve a leading word themselves rather than through tcl::tcl_command_name, so they normalise the :: qualifier at their own call sites. A leading word with its global-namespace qualifier removed.