you are viewing a single comment's thread
view the rest of the comments
[–] 1 point 5 months ago (1 child)

It's not strictly speaking a bug, but the behavior of Advance is a bit confusing. Based on how you use it in the code snippets, I would suggest changing it to

private void Advance() {
    current++;
}

So that it only does what it says, and then changing the place where you read the next char to

char c = Peek();
Advance();

Alternatively, you could rename it to something like ReadChar, which more closely matches its current behavior, since a read is expected to return the data (character) at the current position, and then advance the position

  • source
  • parent
  • hideshow 1 child comment
  • load more comments (1 reply)