colon method

void colon()

Implementation

void colon() {
  final char = advance();

  // A ::label:: token is used in goto statements.
  // The name of a label follows the same conventions as variables.
  if (peek().lexeme == ':') {
    // Consume that second colon.
    advance();
    // Read the name.
    final raw = parseRawName();
    // Consume the following two tokens, throwing if not found.
    read('::');
    // Finally, add the token and return.
    tokens.add(raw.toToken(TokenType.kGotoLabel));
    return;
  }

  tokens.add(char.toToken(TokenType.kColon));
}