1 22 package org.gjt.sp.jedit.syntax; 23 24 import java.lang.reflect.Field ; 25 26 32 public class Token 33 { 34 40 public static byte stringToToken(String value) 41 { 42 try 43 { 44 Field f = Token.class.getField(value); 45 return f.getByte(null); 46 } 47 catch(Exception e) 48 { 49 return -1; 50 } 51 } 53 58 public static String tokenToString(byte token) 59 { 60 return TOKEN_TYPES[token]; 61 } 63 public static final String [] TOKEN_TYPES = new String [] { 65 "NULL", 66 "COMMENT1", 67 "COMMENT2", 68 "COMMENT3", 69 "COMMENT4", 70 "DIGIT", 71 "FUNCTION", 72 "INVALID", 73 "KEYWORD1", 74 "KEYWORD2", 75 "KEYWORD3", 76 "KEYWORD4", 77 "LABEL", 78 "LITERAL1", 79 "LITERAL2", 80 "LITERAL3", 81 "LITERAL4", 82 "MARKUP", 83 "OPERATOR" 84 }; 85 86 public static final byte NULL = 0; 87 88 public static final byte COMMENT1 = 1; 89 public static final byte COMMENT2 = 2; 90 public static final byte COMMENT3 = 3; 91 public static final byte COMMENT4 = 4; 92 public static final byte DIGIT = 5; 93 public static final byte FUNCTION = 6; 94 public static final byte INVALID = 7; 95 public static final byte KEYWORD1 = 8; 96 public static final byte KEYWORD2 = 9; 97 public static final byte KEYWORD3 = 10; 98 public static final byte KEYWORD4 = 11; 99 public static final byte LABEL = 12; 100 public static final byte LITERAL1 = 13; 101 public static final byte LITERAL2 = 14; 102 public static final byte LITERAL3 = 15; 103 public static final byte LITERAL4 = 16; 104 public static final byte MARKUP = 17; 105 public static final byte OPERATOR = 18; 106 108 public static final byte ID_COUNT = 19; 109 110 public static final byte END = 127; 112 113 117 public byte id; 118 119 122 public int offset; 123 124 127 public int length; 128 129 132 public ParserRuleSet rules; 133 134 137 public Token next; 138 140 148 public Token(byte id, int offset, int length, ParserRuleSet rules) 149 { 150 this.id = id; 151 this.offset = offset; 152 this.length = length; 153 this.rules = rules; 154 } 156 160 public String toString() 161 { 162 return "[id=" + id + ",offset=" + offset + ",length=" + length + "]"; 163 } } 165 | Popular Tags |