1 19 20 package org.netbeans.modules.lexer.demo.handcoded.plain; 21 22 import org.netbeans.api.lexer.Language; 23 import org.netbeans.api.lexer.Lexer; 24 import org.netbeans.api.lexer.LexerInput; 25 import org.netbeans.api.lexer.TokenId; 26 import org.netbeans.api.lexer.Token; 27 28 34 35 final class PlainLexer implements Lexer { 36 37 private static final PlainLanguage language = PlainLanguage.get(); 38 39 private LexerInput lexerInput; 40 41 public PlainLexer() { 42 } 43 44 public Object getState() { 45 return null; 46 } 47 48 public void restart(LexerInput input, Object state) { 49 this.lexerInput = input; 50 } 51 52 public Token nextToken() { 53 int ch = lexerInput.read(); 54 while (ch != LexerInput.EOF && ch != '\n') { 55 ch = lexerInput.read(); 56 } 57 58 return (lexerInput.getReadLength() > 0) ? lexerInput.createToken(PlainLanguage.TEXT) 60 : null; } 62 63 } 64 | Popular Tags |