1 19 20 package org.netbeans.lib.lexer.test.dump; 21 22 import org.netbeans.api.lexer.Token; 23 import org.netbeans.spi.lexer.Lexer; 24 import org.netbeans.spi.lexer.LexerInput; 25 import org.netbeans.spi.lexer.LexerRestartInfo; 26 import org.netbeans.spi.lexer.TokenFactory; 27 28 33 final class TextAsSingleTokenLexer implements Lexer<TextAsSingleTokenTokenId> { 34 35 private static final int EOF = LexerInput.EOF; 37 38 private LexerInput input; 39 40 private TokenFactory<TextAsSingleTokenTokenId> tokenFactory; 41 42 TextAsSingleTokenLexer(LexerRestartInfo<TextAsSingleTokenTokenId> info) { 43 this.input = info.input(); 44 this.tokenFactory = info.tokenFactory(); 45 } 46 47 public Object state() { 48 return null; 49 } 50 51 public Token<TextAsSingleTokenTokenId> nextToken() { 52 while (true) { 53 switch (input.read()) { 54 case EOF: 55 return (input.readLength() > 0) 56 ? tokenFactory.createToken(TextAsSingleTokenTokenId.TEXT) 57 : null; 58 } 59 } 60 } 61 62 public void release() { 63 } 64 65 } 66 | Popular Tags |