hoisted getLocation() out of Token and into Token.Stream
[sbp.git] / src / edu / berkeley / sbp / tib / Tib.java
index 39f6071..8ee70ca 100644 (file)
@@ -40,6 +40,7 @@ public class Tib implements Token.Stream<CharToken> {
 
     int _row = 0;
     int _col = 0;
+    public Token.Location getLocation() { return new CharToken.CartesianLocation(_row, _col); }
     public CharToken next() throws IOException {
         if (cur==null) return null;
         if (s != null) {
@@ -47,7 +48,7 @@ public class Tib implements Token.Stream<CharToken> {
                 char c = s.charAt(spos++);
                 if (c=='\n') { _row++; _col = 0; }
                 else _col++;
-                return new CharToken(c, _row, _col);
+                return new CharToken(c);
             }
             s = null;
         }
@@ -55,7 +56,7 @@ public class Tib implements Token.Stream<CharToken> {
             pos = cur.iip+1;
             cur = cur.parent;
             if (cur==null) return null;
-            return CharToken.right(_row, _col);
+            return CharToken.right;
         }
         Object o = cur.child(pos++);
         if (o instanceof String) {
@@ -75,7 +76,7 @@ public class Tib implements Token.Stream<CharToken> {
         }
         cur = (Block)o;
         pos = 0;
-        return CharToken.left(_row, _col);
+        return CharToken.left;
     }
 
     public static Block parse(BufferedReader br) throws Invalid, IOException {