big_code_analysis_ast/token_role.rs
1//! The role a node plays in an expression: operator, operand, or
2//! neither.
3//!
4//! This is a syntactic classification, not a metric one. Whether a node
5//! is an operator or an operand is decided by the grammar — `+` and a
6//! call expression are operators, an identifier and a string literal
7//! are operands — and each language's answer lives in its
8//! [`Getter::get_op_type`](crate::getter::Getter::get_op_type) table
9//! beside the rest of its classifiers.
10//!
11//! Halstead is the metric that consumes it today, and until #1376 the
12//! type was named after that consumer. It is not Halstead-specific:
13//! anything that reasons about operator/operand structure can use it,
14//! which is why it sits in the parse layer rather than the metric.
15//! `metrics::halstead` re-exports it, and keeps the old `HalsteadType`
16//! spelling as a deprecated alias.
17
18/// The role a node plays in an expression.
19pub enum TokenRole {
20 /// The node acts as an operator (`+`, `&&`, a call, an index).
21 Operator,
22 /// The node acts as an operand (an identifier, a literal).
23 Operand,
24 /// The node plays neither role, so it is not counted.
25 Unknown,
26}