string method

void string(
  1. String quote
)

Implementation

void string(String quote) {
  _lexemeBuffer.clear();
  while (peek() != quote && !isAtEnd()) {
    if (peek() == '\n') line++;
    _lexemeBuffer.write(advance());
  }

  if (isAtEnd()) {
    addToken(TokenType.unknown);
    return;
  }

  advance(); // The closing quote

  addToken(TokenType.string, _lexemeBuffer.toString());
}