package token;

import static java.text.MessageFormat.format;

import error.CriticalLineColumnException;
import error.LineColumnException;
import file.FilePosition;

public interface TokenFactory {

    Token createToken(String text, FilePosition position);

    Token createEofToken(FilePosition position);

    public static class EmptyTokenTextException extends CriticalLineColumnException {

        private static final long serialVersionUID = 1L;

        public EmptyTokenTextException(FilePosition position) {
            super(position);
        }

        @Override
        public String getMessagePrefix() {
            return "empty token";
        }
    }

    public static class BadCharacterException extends LineColumnException {

        private static final long serialVersionUID = 1L;
        private String text;

        public BadCharacterException(String text, FilePosition position) {
            super(position);
            this.text = text;
        }

        @Override
        public String getMessagePrefix() {
            return format("illegal character >>{0}<<", text);
        }
    }

}
