Noir::CharOffsets
Char <-> byte offsets and line numbers for one string, built in one pass.
Analyzers that keep CHAR indices (to agree with the char-indexed masking
lexers) pay O(offset) for every String#[], String#match(re, pos) and
MatchData#begin/#end once the string holds a single multi-byte char, and
Analyzer#line_number_for_index is O(offset) even on ASCII. Done per route
that is quadratic in the route count. These forms keep the char semantics
at O(1) / O(log n) per call.
Constructors
Instance methods
Whether the char at char_pos is ASCII whitespace (false past the end).
match.begin(n) / match.end(n) as char indices.
content.index(regex, char_pos).
content.index(char, char_pos) for an ASCII char.
1-based line of char_pos; same answer as Analyzer#line_number_for_index.
content.match(regex, char_pos).