pub enum NumVal {
Scalar(u64),
Range {
lo: u64,
hi: u64,
},
Concat(Vec<u64>),
}Expand description
A numeric terminal, in any of the three radices. The radix is not retained: %d65,
%b1000001 and %x41 all parse to the same node and print as %x41 (SCOPE.md 6.7, D37).
Variants§
Scalar(u64)
A single value, e.g. %x41.
Range
An inclusive range, e.g. %x41-5A.
Concat(Vec<u64>)
A concatenation, e.g. %x41.42.43 (Erratum 3076).
Implementations§
Source§impl NumVal
impl NumVal
Sourcepub fn is_representable(&self) -> bool
pub fn is_representable(&self) -> bool
Whether this terminal can match anything at all (SCOPE.md 6.1).
The matching domain is Unicode scalar values, so a value above U+10FFFF or inside the
surrogate block matches nothing. Being unrepresentable is not a structural error: the
grammar loads, and only a start rule that can reach the terminal is refused (D4). Real
grammars written over octets — RFC 9110’s obs-text = %x80-FF — stay usable this way.
Sourcepub const fn scalars_in(lo: u64, hi: u64) -> u64
pub const fn scalars_in(lo: u64, hi: u64) -> u64
How many Unicode scalar values lo..=hi contains.
The generator picks uniformly among them, so this has to exclude the surrogate block rather than just measure the span.
Sourcepub fn nth_scalar(lo: u64, hi: u64, index: u64) -> Option<char>
pub fn nth_scalar(lo: u64, hi: u64, index: u64) -> Option<char>
The index-th Unicode scalar value in lo..=hi, skipping the surrogate block.
None once index reaches NumVal::scalars_in, so the generator can index without
first checking the bound.