1 19 20 package org.netbeans.lib.lexer; 21 22 import org.netbeans.lib.editor.util.ArrayUtilities; 23 24 32 33 public interface CharProvider { 34 35 38 int read(); 39 40 43 char readExisting(int index); 44 45 48 int readIndex(); 49 50 54 int deepRawLength(int length); 55 56 60 int deepRawLengthShift(int index); 61 62 67 void backup(int count); 68 69 73 int tokenLength(); 74 75 86 void tokenRecognized(int tokenLength); 87 88 93 void tokenApproved(); 94 95 108 void collectExtraPreprocessedChars(ExtraPreprocessedChars epc, 109 int prepStartIndex, int prepEndIndex, int topPrepEndIndex); 110 111 112 115 public static final class ExtraPreprocessedChars { 116 117 private int preStartIndex; 118 119 private int postEndIndex; 120 121 private char[] extraPrepChars = ArrayUtilities.emptyCharArray(); 122 123 private int[] extraRawLengthShifts; 124 125 public void ensureExtraLength(int length) { 126 int preLength = extraPrepChars.length - preStartIndex; 127 length += postEndIndex + preLength; 128 if (length > extraPrepChars.length) { 129 length <<= 1; 130 extraPrepChars = ArrayUtilities.charArray(extraPrepChars, length, 131 postEndIndex, preStartIndex - postEndIndex); 132 extraRawLengthShifts = ArrayUtilities.intArray(extraRawLengthShifts, 133 length, postEndIndex, preStartIndex - postEndIndex); 134 preStartIndex = extraPrepChars.length - preLength; 135 } 136 } 137 138 public void insert(char ch, int rawLengthShift) { 139 preStartIndex--; 140 extraPrepChars[extraPrepChars.length - preStartIndex] = ch; 141 extraRawLengthShifts[extraPrepChars.length - preStartIndex] = rawLengthShift; 142 } 143 144 public void append(char ch, int rawLengthShift) { 145 extraPrepChars[postEndIndex] = ch; 146 extraRawLengthShifts[postEndIndex] = rawLengthShift; 147 postEndIndex++; 148 } 149 150 public void clear() { 151 preStartIndex = extraPrepChars.length; 152 postEndIndex = 0; 153 } 154 155 public int preStartIndex() { 156 return preStartIndex; 157 } 158 159 public int postEndIndex() { 160 return postEndIndex; 161 } 162 163 public char[] extraPrepChars() { 164 return extraPrepChars; 165 } 166 167 public int[] extraRawLengthShifts() { 168 return extraRawLengthShifts; 169 } 170 171 } 172 173 } 174 | Popular Tags |