big-code-analysis-ast 2.5.1

Parse and classification layer behind big-code-analysis (internal, version-locked)
Documentation
//! Mozcpp's role rows. The dialect owns no file extension and shares
//! Cpp's grammar shape with different kind ids, so its rows splice the
//! same `cpp_family_*` fragments Cpp's do (`roles/c_family.rs`,
//! contract 5 of #1690): the paying-construct rows (#1694, #1695), the
//! space tree (#1696) and the control flow (#1697) are declared through
//! them, the Halstead keyword rows are declared (#1693) and the rest
//! are pending or absent as Cpp's are.
//! Nothing routes a file to this dialect, so no corpus snapshot reaches
//! these rows; `tests/parity/cpp_mozcpp_parity.rs` holds the two
//! dialects together.

use crate::Mozcpp;
use crate::role_table;
use crate::roles::c_family::{
    c_family_calls, c_family_conditional_kinds, c_family_decl_keywords, c_family_doc_conditionals,
    c_family_doc_entries, c_family_doc_gates, c_family_modifiers, c_family_primitives,
    c_family_strings, cpp_doc_entries, cpp_family_binary_owners, cpp_family_comparison_payers,
    cpp_family_containers, cpp_family_exits, cpp_family_func_openers, cpp_family_gates,
    cpp_family_loops, cpp_family_short_circuit_payers,
};
use crate::roles::control_flow::else_if_parent_clause_gate;

// The documentation gates, per dialect (#1699).
c_family_doc_gates!(MozcppCode);
// The `DocTarget` row's conditional owners as a kind test (#1795).
c_family_conditional_kinds!(Mozcpp);

cpp_family_gates!(Mozcpp);
// The chained `if` sits directly inside an `else_clause`; a nested one
// under `else { … }` sits inside the compound statement (#1697).
else_if_parent_clause_gate!(Mozcpp, ElseClause);

role_table! {
    lang: Mozcpp;
    Call { owns [..c_family_calls!()] }
    // `R"(…)"` joins the family's two: it is one string-like token to
    // `find` and the dump (#398, the peer of #391 for Rust).
    StringLit { owns [..c_family_strings!(), RawStringLiteral] }
    // The C++ binary operators are one `binary_expression` kind (the
    // aliased `BinaryExpression2` at the pinned grammar; the unsuffixed
    // id is the never-emitted pre-alias) plus the fold, told apart by
    // the `operator` field, so each row's owners are gated on that
    // field holding one of its payers and each payer on applying its
    // operator (`roles/c_family.rs` has both lists and their
    // derivations — #1448, #1522, #1525, #1533). A `requires` clause or
    // expression is compile-time and its operators decide nothing; the
    // rows do not know that, because a parenthesised constraint parses
    // as an ordinary `binary_expression` and only the root crate's
    // `ConstraintReach` can see the clause above it. The consumers read
    // the rows *under* that reach.
    Comparison {
        owns [..cpp_family_binary_owners!()]
        pays [..cpp_family_comparison_payers!()]
        project "operator"
    }
    ShortCircuit {
        owns [..cpp_family_binary_owners!()]
        pays [..cpp_family_short_circuit_payers!()]
        project "operator"
    }
    EagerLogical { absent "C++'s `&` / `|` / `^` are bitwise; `and` / `or` are the lazy spellings" }
    // The `conditional_expression` owns the ternary and its `?` pays,
    // ungated: the grammar spells a bare `?` in no other production. The
    // GNU elision `a ?: b` is the same node with its `consequence` field
    // empty, which the ABC slot walker reads by field (#1102).
    Ternary {
        owns [ConditionalExpression]
        pays [QMARK]
        project "operator"
    }
    NullSafe { absent "C++ has no optional navigation or null coalescing" }
    // A `case_statement` is the grammar's node for a `case X:` label
    // and a `default:` label alike; the arm owns a decision when it
    // holds the `case` keyword, which pays — one per label, so a
    // fall-through run `case 2: case 3:` is two. The `default` keyword
    // is the fallback and pays nothing (lesson 11, #469); Halstead
    // bills it as the keyword it is through the byte-less arm.
    CaseArm {
        owns [CaseStatement(holds_payer)]
        pays [Case]
        excludes [Default "the fallback label, no decision (lesson 11, #469)"]
    }
    Guard { absent "C++ has no guard clause on a case or a function head" }
    // The C family's control flow (#1697): the one-kind rows are spelled
    // inline, the loop and exit lists are the two C++ grammars' own
    // fragments (`cpp_family_loops!`, `cpp_family_exits!` in
    // `roles/c_family.rs`), so this is Cpp's table under other ids. The
    // `ElseIf` gate is emitted beside this table. `Catch` pays at the `catch`
    // keyword, which is where this dialect differs from ObjC.
    Branch { owns [IfStatement] pays [If] }
    Switch { owns [SwitchStatement] }
    Loop { owns [..cpp_family_loops!()] pays [For, While] }
    Catch { owns [CatchClause] pays [Catch] }
    ElseIf { owns [IfStatement(gated_by continues_else_clause)] pays [] }
    Exit { owns [..cpp_family_exits!()] }
    // Cpp's three keyword rows, verbatim. The dialect shares Cpp's
    // grammar shape and owns no file extension, so nothing routes to it
    // and no corpus snapshot reaches these rows;
    // `tests/parity/cpp_mozcpp_parity.rs` holds the two vocabularies
    // together. The derivations are on the Cpp rows.
    Modifier {
        owns [
            ..c_family_modifiers!(),
            Virtual, Mutable, Constinit, Consteval, Explicit, Friend, Public, Private,
            Protected, Override, Final, Noexcept2,
        ]
    }
    DeclKeyword { owns [..c_family_decl_keywords!(), Class, Namespace, Template, Typename, Using] }
    Primitive { owns [..c_family_primitives!()] }
    // The shared C++ openers and containers (`roles/c_family.rs`); the
    // lambda is a closure that opens no space.
    FuncOpener { owns [..cpp_family_func_openers!()] }
    Closure { owns [LambdaExpression] }
    Container { owns [..cpp_family_containers!()] }
    // A `field_declaration` in a class body — a data member, or a
    // bodiless member function the method consumer tells apart by its
    // declarator (#1300). Which it is, and the access section it sits
    // in, is the consumers' reading.
    Member { owns [FieldDeclaration] }
    // The one comment kind, a `DocComment` owner under Doxygen's marker
    // gate (#1699).
    Comment { owns [Comment] }
    DocComment { owns [Comment(text_gated_by opens_with_doxygen_marker no_chain)] }
    Docstring { absent "C++ documents with comments, not string literals" }
    // What Doxygen documents from a doc block before it: the entries of
    // `roles/c_family.rs`'s fragment, and every
    // preprocessor conditional holding an entry in any branch
    // (`conditional_declares`, memoised). The `ERROR` node holding an
    // entry is the Checker's clause. Most targets are outside the
    // space-tree rows — a macro, a typedef, an enumerator, a field, a
    // conditional — the parity exceptions `roles/doc_tests/parity.rs` records.
    DocTarget {
        owns [
            ..c_family_doc_entries!(),
            ..cpp_doc_entries!(),
            ..c_family_doc_conditionals!(),
        ]
    }
    DocRunOpener { absent "Doxygen attaches every block to an entry or the file; none documents by its own content" }
    DocRunDirective { absent "Doxygen reads no directive comment" }
    DocBodyResidual { absent "Doxygen reads every block in a body as the function's in-body description; nothing withholds one" }
}