X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FLexer.java;h=1e2494ee605840d54868b690ced506ca43792cf6;hb=cba642c3dd58d20b4ecebe4ea96232cdd983b17e;hp=f08ebce6cb0bb37bccd5192a5da638f3a3ced742;hpb=77f51cd3e157cf6fd2ae85ce774444bb85ea7b81;p=org.ibex.core.git diff --git a/src/org/xwt/js/Lexer.java b/src/org/xwt/js/Lexer.java index f08ebce..1e2494e 100644 --- a/src/org/xwt/js/Lexer.java +++ b/src/org/xwt/js/Lexer.java @@ -108,7 +108,6 @@ class Lexer implements Tokens { case 'n': return s.equals("null") ? NULL : -1; case 't': c=s.charAt(3); if (c=='e') { if (s.charAt(2)=='u' && s.charAt(1)=='r') return TRUE; } - else if (c=='s') { if (s.charAt(2)=='i' && s.charAt(1)=='h') return THIS; } return -1; case 'w': if (s.equals("with")) return RESERVED; else return -1; case 'v': if (s.equals("void")) return RESERVED; else return -1; @@ -342,6 +341,8 @@ class Lexer implements Tokens { 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; } @@ -354,7 +355,11 @@ class Lexer implements Tokens { 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; }