package util;

import java.util.HashSet;
import java.util.Set;

public final class Characters {

    private Characters() {}

    public static final int EOF = -1;

    public static final char AT_SIGN = '@';
    public static final char BACKQUOTE = '`';
    public static final char BACKSLASH = '\\';
    public static final char COMMA = ',';
    public static final char DASH = '-';
    public static final char DOUBLE_QUOTE = '\"';
    public static final char HASH = '#';
    public static final char LEFT_PARENTHESIS = '(';
    public static final char LEFT_SQUARE_BRACKET = '[';
    public static final char NEWLINE = '\n';
    public static final char PERIOD = '.';
    public static final char PLUS = '+';
    public static final char RIGHT_PARENTHESIS = ')';
    public static final char RIGHT_SQUARE_BRACKET = ']';
    public static final char SEMICOLON = ';';
    public static final char SINGLE_QUOTE = '\'';
    public static final char UNICODE_ESCAPE = '\u001B';
    public static final char UNICODE_NULL = '\u0000';

    public static final Set<Character> illegalIdentifierCharacters = new HashSet<>();

    static {
        illegalIdentifierCharacters.add(AT_SIGN);
        illegalIdentifierCharacters.add(BACKQUOTE);
        illegalIdentifierCharacters.add(BACKSLASH);
        illegalIdentifierCharacters.add(COMMA);
        illegalIdentifierCharacters.add(DOUBLE_QUOTE);
        illegalIdentifierCharacters.add(HASH);
        illegalIdentifierCharacters.add(LEFT_PARENTHESIS);
        illegalIdentifierCharacters.add(LEFT_SQUARE_BRACKET);
        illegalIdentifierCharacters.add(PERIOD);
        illegalIdentifierCharacters.add(RIGHT_PARENTHESIS);
        illegalIdentifierCharacters.add(RIGHT_SQUARE_BRACKET);
        illegalIdentifierCharacters.add(SEMICOLON);
        illegalIdentifierCharacters.add(SINGLE_QUOTE);
    }

    public static boolean isLegalIdentifierCharacter(char c) {
        return (!Character.isWhitespace(c)) && (!illegalIdentifierCharacters.contains(c));
    }

    public static boolean isLegalStringCharacter(char c) {
        return true;
    }

    public static boolean isNumberPrefix(char c) {
        return c == DASH || c == PLUS;
    }

}
