package procesador;

public class Terminal implements ItemPila {

    private final int tokenId;
    private final String tokenLexema;
    private final Atributos atributos;

    public Terminal(int tokenId) {
        this.tokenId = tokenId;
        this.tokenLexema = ALex.id_tok.get(tokenId);
        this.atributos = new Atributos();
    }

    public Terminal(String tokenLexema) {
        this.tokenId = ALex.tok_id.get(tokenLexema.toUpperCase());
        this.tokenLexema = tokenLexema;
        this.atributos = new Atributos();
    }

    public Terminal(String tokenLexema, Atributos atributos) {
        this.tokenId = ALex.tok_id.get(tokenLexema.toUpperCase());
        this.tokenLexema = tokenLexema.toUpperCase();
        this.atributos = atributos;
    }

    public Atributos getAtributos() {
        return atributos;
    }

    public int getTokenId() {
        return tokenId;
    }

    public String getTokenLexema() {
        return tokenLexema;
    }

    @Override
    public Tipo getTipo() {
        return Tipo.TERMINAL;
    }

    @Override
    public String debug() {
        return "T(" + tokenLexema + " " + atributos.toString() + ")";
    }

    @Override
    public String toString() {
        return "T(" + tokenLexema + ")";
    }

    @Override
    public ItemPila clone() {
        return new Terminal(
                this.tokenLexema,
                this.atributos.clone()
        );
    }

}
