My experimental lexer generator now uses the buffer range. https://github.com/Hackerpilot/Dscanner/tree/NewLexer/stdx The problem that I have with it right now is that range.lookbehind(1).length != range.lookahead(1).length. This was confusing.