1 package org.codehaus.groovy.syntax.lexer; 2 3 import org.codehaus.groovy.syntax.ReadException; 4 5 10 11 public class TextLexerBase extends LexerBase implements Delimiter 12 { 13 14 protected boolean delimited = true; protected boolean finished = true; 17 18 23 24 public void delimit( boolean delimited ) 25 { 26 this.delimited = delimited; 27 } 28 29 30 31 34 35 public boolean isDelimited() 36 { 37 return this.delimited; 38 } 39 40 41 42 45 46 public boolean isFinished() 47 { 48 return finished; 49 } 50 51 52 53 57 58 protected void restart() 59 { 60 finished = false; 61 } 62 63 64 65 68 69 protected void finish() 70 { 71 finished = true; 72 } 73 74 75 76 77 78 81 82 85 86 public char la(int k) throws LexerException, ReadException 87 { 88 if( finished ) 89 { 90 return CharStream.EOS; 91 } 92 else if( source != null ) 93 { 94 return source.la(k); 95 } 96 else 97 { 98 return CharStream.EOS; 99 } 100 } 101 102 103 104 107 108 public char consume() throws LexerException, ReadException 109 { 110 if( finished ) 111 { 112 return CharStream.EOS; 113 } 114 else if( source != null ) 115 { 116 return source.consume(); 117 } 118 else 119 { 120 return CharStream.EOS; 121 } 122 } 123 124 } 125 | Popular Tags |