1 19 20 package org.netbeans.spi.lexer; 21 22 import org.netbeans.lib.lexer.CharPreprocessorOperation; 23 import org.netbeans.lib.lexer.UnicodeEscapesPreprocessor; 24 25 26 38 39 public abstract class CharPreprocessor { 40 41 44 public static CharPreprocessor createUnicodeEscapesPreprocessor() { 45 return new UnicodeEscapesPreprocessor(); 46 } 47 48 private CharPreprocessorOperation operation; 49 50 51 105 protected abstract void preprocessChar(); 106 107 114 protected abstract boolean isSensitiveChar(char ch); 115 116 124 protected abstract int maxLookahead(); 125 126 132 protected final int inputRead() { 133 return operation.inputRead(); 134 } 135 136 141 protected final void inputBackup(int count) { 142 operation.inputBackup(count); 143 } 144 145 151 protected final void outputOriginal(int ch) { 152 operation.outputOriginal(ch); 153 } 154 155 170 protected final void outputPreprocessed(char ch, int extraInputLength) { 171 assert (extraInputLength > 0) : "extraInputLength > 0 expected."; 172 operation.outputPreprocessed(ch, extraInputLength); 173 } 174 175 180 protected final void notifyError(String errorMessage) { 181 operation.notifyError(errorMessage); 182 } 183 184 void init(CharPreprocessorOperation operation) { 185 this.operation = operation; 186 } 187 188 } 189 | Popular Tags |