1 19 package org.netbeans.modules.css.text.syntax.javacc.lib; 20 21 29 public class StringParserInput extends SimpleCharStream implements CharStream { 30 31 private char[] buffer; 32 33 34 private int pos; 35 36 37 private int begin; 38 39 40 private int len; 41 42 43 private int end; 44 45 public StringParserInput() {} 46 47 48 public void setString(String s) { 49 buffer = s.toCharArray(); 50 begin = pos = 0; 51 len = s.length(); 52 end = len; 53 } 54 55 56 public void setBuffer(char[] buf, int offset, int len) { 57 buffer = buf; 58 begin = pos = offset; 59 this.len = len; 60 end = offset + len; 61 } 62 63 68 public char readChar() throws java.io.IOException { 69 if (pos >= end) 70 throw new java.io.EOFException (); 71 return buffer[pos++]; 72 } 73 74 79 public int getColumn() { 80 return 0; 81 } 82 83 88 public int getLine() { 89 return 0; 90 } 91 92 96 public int getEndColumn() { 97 return 0; 98 } 99 100 104 public int getEndLine() { 105 return 0; 106 } 107 108 112 public int getBeginColumn() { 113 return 0; 114 } 115 116 120 public int getBeginLine() { 121 return 0; 122 } 123 124 130 public void backup(int amount) { 131 if (pos > 1) 132 pos -= amount; 133 } 134 135 140 public char BeginToken() throws java.io.IOException { 141 begin = pos; 142 return readChar (); 143 } 144 145 151 public String GetImage() { 152 return new String (buffer, begin, pos-begin); 153 } 154 155 156 157 public int getLength() { 158 return pos - begin; 159 } 160 161 172 public char[] GetSuffix(int l) { 173 char[] ret = new char[l]; 174 System.arraycopy(buffer, pos - l, ret, 0, l); 175 return ret; 176 } 177 178 184 public void Done() { 185 } 186 187 public String toString() { 188 return "StringParserInput\n Pos:" + pos + " len:" + len + " #################\n" + buffer; } 190 } 191 | Popular Tags |