Get the next character in the source string. @return The next character, or 0 if past the end of the source string.
()
| 146 | * @return The next character, or 0 if past the end of the source string. |
| 147 | */ |
| 148 | public char next() { |
| 149 | int c; |
| 150 | if (this.usePrevious) { |
| 151 | this.usePrevious = false; |
| 152 | c = this.previous; |
| 153 | } else { |
| 154 | try { |
| 155 | c = this.reader.read(); |
| 156 | } catch (IOException exception) { |
| 157 | throw new RuntimeException(exception); |
| 158 | } |
| 159 | |
| 160 | if (c <= 0) { // End of stream |
| 161 | this.eof = true; |
| 162 | c = 0; |
| 163 | } |
| 164 | } |
| 165 | this.index += 1; |
| 166 | if (this.previous == '\r') { |
| 167 | this.line += 1; |
| 168 | this.character = c == '\n' ? 0 : 1; |
| 169 | } else if (c == '\n') { |
| 170 | this.line += 1; |
| 171 | this.character = 0; |
| 172 | } else { |
| 173 | this.character += 1; |
| 174 | } |
| 175 | this.previous = (char) c; |
| 176 | return this.previous; |
| 177 | } |
| 178 | |
| 179 | |
| 180 | /** |