Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /**
* One ADR-025 case label, reduced to which grammar alternative matched and
* what it carries.
*
* #1445 box 3: `SwitchGenerator` asked a `CaseLabelContext` six questions in a
* fixed order -- qualified type, identifier, integer, hex, binary, char -- and
* took the first that answered. That order IS the discrimination, so the union
* states it and the planner picks the arm in the same order.
*
* The three numeric arms stay distinct because they are rendered differently:
* a binary literal is converted to hex (Issue #114, through `BigInt` so a
* value above 2^53 keeps its precision), and a char literal is the one that
* ignores a leading minus -- `'-'` is not a negative character.
*/
type TPlannedCaseLabel =
/** `EState.IDLE` -- the identifiers of a qualified type, in order. */
| { readonly kind: "qualified"; readonly parts: readonly string[] }
/** A bare identifier: a const, or an enum member the switch's type declares. */
| { readonly kind: "identifier"; readonly name: string }
/** An integer or hex literal, with the minus that may precede it. */
| {
readonly kind: "numeric";
readonly text: string;
readonly negative: boolean;
}
/** A binary literal, which renders as hex. */
| {
readonly kind: "binary";
readonly text: string;
readonly negative: boolean;
}
/** A char literal, which never takes a minus. */
| { readonly kind: "char"; readonly text: string }
/**
* No alternative matched.
*
* The node-walking version fell through to `""` here, and that is preserved
* rather than made an error: the grammar admits nothing else today, so an
* arm that cannot be reached is not the place to add a diagnostic.
*/
| { readonly kind: "none" };
export default TPlannedCaseLabel;
|