org.onetwo.common.lexer.JLexerUtils Maven / Gradle / Ivy
package org.onetwo.common.lexer;
public final class JLexerUtils {
// public static final int EOF = -1;
public final static byte EOI = 0x1A;
private static final boolean[] WHITE_SPACE = new boolean[256];
static {
WHITE_SPACE[' '] = true;
WHITE_SPACE['\n'] = true;
WHITE_SPACE['\r'] = true;
WHITE_SPACE['\t'] = true;
WHITE_SPACE['\f'] = true;
WHITE_SPACE['\b'] = true;
}
private static final boolean[] IDENTIFIERS = new boolean[256];
static {
for(char c=0; c='a' && c<='z'){
IDENTIFIERS[c] = true;
}else if(c>='A' && c<='Z'){
IDENTIFIERS[c] = true;
}else if(c>='0' && c<='9'){
IDENTIFIERS[c]= true;
}
}
IDENTIFIERS['_'] = true;
}
private static final boolean[] NUMBER_CHARS = new boolean[256];
static {
for(char c=0; c='0' && c<='9'){
NUMBER_CHARS[c]= true;
}
}
NUMBER_CHARS['-'] = true;
NUMBER_CHARS['.'] = true;
}
private static final boolean[] JNUMBER_CHARS = new boolean[256];
static {
for(char c=0; c='0' && c<='9'){
JNUMBER_CHARS[c]= true;
}
}
JNUMBER_CHARS['.'] = true;
JNUMBER_CHARS['f'] = true;
JNUMBER_CHARS['F'] = true;
JNUMBER_CHARS['d'] = true;
JNUMBER_CHARS['D'] = true;
JNUMBER_CHARS['l'] = true;
JNUMBER_CHARS['L'] = true;
}
private static final boolean[] FIRST_IDENTIFIERS = new boolean[256];
static {
for(char c=0; c='a' && c<='z'){
FIRST_IDENTIFIERS[c] = true;
}else if(c>='A' && c<='Z'){
FIRST_IDENTIFIERS[c] = true;
}
}
FIRST_IDENTIFIERS['_'] = true;
}
public static boolean isWhiteSpace(char ch){
return ch < WHITE_SPACE.length && WHITE_SPACE[ch];
}
public static boolean isNumberChar(char ch){
try {
return NUMBER_CHARS[ch];
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
public static boolean isJavaNumberChar(char ch){
return JNUMBER_CHARS[ch];
}
public static boolean isIdentifier(char ch){
return ch
© 2015 - 2025 Weber Informatics LLC | Privacy Policy