Build a Compiler from Scratch, Part 1.1: A Hello World of sorts
It has become common practice to start with a "Hello World" program when learning a new programming language.
This is a simple program that outputs the text "Hello, World!" to the screen. While writing such a program
is a trivial task with most prog...
blog.sylver.dev22 min read
impl Iterator for Lexer<'_> { type Item = (Token, Span); fn next(&mut self) -> Option<Self::Item> { - self.next_token(); + self.emit_next_tokens(); + self.token_queue.pop_front() } }One question here
emit_next_tokens(); can push one or more tokens to the queue.
pop_front(); only consumes one. Does this not mean the queue will race ahead of the iteration?
I tried setting type Item = (Token, Span, u32 /Current Queue Size/) with a longer bit of code with a lot of indentation and it did race ahead. It's possible I missed something else elsewhere.