package com.duomg.lombard;
import java.util.Formatter;
class Token {
final TokenType type;
final String lexeme;
final Object object;
final int line;
private final String stringRepr;
Token(TokenType type, String lexeme, Object object, int line) {
this.type = type;
this.lexeme = lexeme;
this.object = object;
this.line = line;
var builder = new StringBuilder();
var formatter = new Formatter(builder);
formatter.format("Token { type: %s, lexeme: '%s', object: %s, line: %d }", type, lexeme, object, line);
this.stringRepr = builder.toString();
}
@Override
public String toString() {
return this.stringRepr;
}
}