/** for debugging */
public static void main(String[] s) throws Exception {
- Lexer l = new Lexer(new InputStreamReader(System.in));
+ Lexer l = new Lexer(new InputStreamReader(System.in), "stdin", 0);
int tok = 0;
while((tok = l.getToken()) != -1) System.out.println(codeToString[tok]);
}
protected int col = 0;
/** the name of the source code file being lexed */
- protected String sourceName = "unknown";
+ protected String sourceName;
private SmartReader in;
- public Lexer(Reader r) throws IOException { in = new SmartReader(r); }
+ public Lexer(Reader r, String sourceName, int line) throws IOException {
+ this.sourceName = sourceName;
+ this.line = line;
+ in = new SmartReader(r);
+ }
// Predicates ///////////////////////////////////////////////////////////////////////
public int getToken() throws IOException {
number = null;
string = null;
- if (pushBackDepth == 0) return _getToken();
+ if (pushBackDepth == 0) return op = _getToken();
pushBackDepth--;
op = pushBackInts[pushBackDepth];
if (pushBackObjects[pushBackDepth] != null) {