* Contributor(s): Roger Lawrence, Mike McCabe
*/
-// FIXME: mark lots of these methods 'final' so they get inlined
-
package org.xwt.js;
import java.io.*;
return STRING;
}
- public int _getToken() throws IOException {
+ private int _getToken() throws IOException {
int c;
do { c = in.read(); } while (c == '\u0020' || c == '\u0009' || c == '\u000C' || c == '\u000B' || c == '\n' );
if (c == -1) return -1;
public void unread() throws IOException { unread((char)lastread); }
public void unread(char c) throws IOException {
reader.unread(c);
+ if(c == '\n') col = -1;
+ else col--;
if (accumulator != null) accumulator.setLength(accumulator.length() - 1);
}
public boolean match(char c) throws IOException { if (peek() == c) { reader.read(); return true; } else return false; }
lastread = reader.read();
if (accumulator != null) accumulator.append((char)lastread);
if (lastread != '\n' && lastread != '\r') col++;
- if (lastread == '\n') { parserLine = ++line; col = 0; }
+ if (lastread == '\n') {
+ // col is -1 if we just unread a newline, this is sort of ugly
+ if (col != -1) parserLine = ++line;
+ col = 0;
+ }
return lastread;
}
private Object[] pushBackObjects = new Object[10];
/** push back a token */
- public void pushBackToken(int op, Object obj) {
+ public final void pushBackToken(int op, Object obj) {
if (pushBackDepth >= pushBackInts.length - 1) {
int[] newInts = new int[pushBackInts.length * 2];
System.arraycopy(pushBackInts, 0, newInts, 0, pushBackInts.length);
}
/** push back the most recently read token */
- public void pushBackToken() { pushBackToken(op, number != null ? (Object)number : (Object)string); }
+ public final void pushBackToken() { pushBackToken(op, number != null ? (Object)number : (Object)string); }
/** read a token but leave it in the stream */
- public int peekToken() throws IOException {
+ public final int peekToken() throws IOException {
int ret = getToken();
pushBackToken();
return ret;
}
/** read a token */
- public int getToken() throws IOException {
+ public final int getToken() throws IOException {
number = null;
string = null;
if (pushBackDepth == 0) {