1 package org.apache.oro.text.regex; 2 3 59 60 68 final class OpCode { 69 70 private OpCode() { } 71 72 static final char _END = 0, _BOL = 1, _MBOL = 2, _SBOL = 3, _EOL = 4, _MEOL = 5, _SEOL = 6, _ANY = 7, _SANY = 8, _ANYOF = 9, _CURLY = 10, _CURLYX = 11, _BRANCH = 12, _BACK = 13, _EXACTLY = 14, _NOTHING = 15, _STAR = 16, _PLUS = 17, _ALNUM = 18, _NALNUM = 19, _BOUND = 20, _NBOUND = 21, _SPACE = 22, _NSPACE = 23, _DIGIT = 24, _NDIGIT = 25, _REF = 26, _OPEN = 27, _CLOSE = 28, _MINMOD = 29, _GBOL = 30, _IFMATCH = 31, _UNLESSM = 32, _SUCCEED = 33, _WHILEM = 34; 112 static final int _operandLength[] = { 114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 115 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 116 }; 117 118 static final char _opType[] = { 119 _END, _BOL, _BOL, _BOL, _EOL, _EOL, _EOL, _ANY, _ANY, _ANYOF, _CURLY, 120 _CURLY, _BRANCH, _BACK, _EXACTLY, _NOTHING, _STAR, _PLUS, _ALNUM, 121 _NALNUM, _BOUND, _NBOUND, _SPACE, _NSPACE, _DIGIT, _NDIGIT, _REF, 122 _OPEN, _CLOSE, _MINMOD, _BOL, _BRANCH, _BRANCH, _END, _WHILEM 123 }; 124 125 static final char _opLengthVaries[] = { 126 _BRANCH, _BACK, _STAR, _PLUS, _CURLY, _CURLYX, _REF, _WHILEM 127 }; 128 129 static final char _opLengthOne[] = { 130 _ANY, _SANY, _ANYOF, _ALNUM, _NALNUM, _SPACE, _NSPACE, _DIGIT, _NDIGIT 131 }; 132 133 static final int _NULL_OFFSET = -1; 134 static final char _NULL_POINTER = 0; 135 136 static final int _getNextOffset(char[] program, int offset) { 137 return ((int)program[offset + 1]); 138 } 139 140 static final char _getArg1(char[] program, int offset) { 141 return program[offset + 2]; 142 } 143 144 static final char _getArg2(char[] program, int offset) { 145 return program[offset + 3]; 146 } 147 148 static final int _getOperand(int offset) { 149 return (offset + 2); 150 } 151 152 static final boolean _isInArray(char ch, char[] array, int start) { 153 while(start < array.length) 154 if(ch == array[start++]) 155 return true; 156 return false; 157 } 158 159 static final int _getNextOperator(int offset) { return (offset + 2); } 160 static final int _getPrevOperator(int offset) { return (offset - 2); } 161 162 static final int _getNext(char[] program, int offset) { 163 int offs; 164 165 if(program == null) 166 return _NULL_OFFSET; 167 168 169 offs = _getNextOffset(program, offset); 170 if(offs == _NULL_POINTER) 171 return _NULL_OFFSET; 172 173 if(program[offset] == OpCode._BACK) 174 return (offset - offs); 175 176 return (offset + offs); 177 } 178 179 static final boolean _isWordCharacter(char token) { 182 return ((token >= 'a' && token <= 'z') || 183 (token >= 'A' && token <= 'Z') || 184 (token >= '0' && token <= '9') || 185 (token == '_')); 186 } 187 } 188 | Popular Tags |