Implement double buffered lexer
Inline utility function unneeded elsewhere