add Input.getName()
[sbp.git] / src / edu / berkeley / sbp / tib / Tib.java
index a3fd568..41aab5c 100644 (file)
@@ -7,10 +7,6 @@ import edu.berkeley.sbp.chr.*;
 import java.util.*;
 import java.io.*;
 
-// TODO: multiple {{ }} for superquotation
-// TODO: strings
-// TODO: comments
-
 /**
  *   A slow, ugly, inefficient, inelegant, ad-hoc parser for TIB files.
  *
@@ -24,7 +20,7 @@ import java.io.*;
  */
 public class Tib implements Input<Character> {
 
-    public String showRegion(Region<Character> r) { return null; }
+    public String showRegion(Region<Character> r) { return ""; }
 
     public Tib(String s) throws IOException { this(new StringReader(s)); }
     public Tib(Reader r) throws IOException { this(new BufferedReader(r)); }
@@ -35,7 +31,7 @@ public class Tib implements Input<Character> {
         //cur = parse(br);
         //System.out.println("\rparsing: \"" + cur.toString(0, -1) + "\"");
     }
-
+    public String getName() { return null; }
     private String s = "";
     int pos = 0;
     int spos = 0;
@@ -54,12 +50,15 @@ public class Tib implements Input<Character> {
     boolean indenting = true;
     int indentation = 0;
     private ArrayList<Integer> istack = new ArrayList<Integer>();
+    private static boolean debug = "true".equals(System.getProperty("tib.debug", "false"));
     public Character next() throws IOException {
         Character ret = nextc();
-        if      (ret==null) return null;
-        else if (ret==left)  System.out.print("\033[31m{\033[0m");
-        else if (ret==right) System.out.print("\033[31m}\033[0m");
-        else System.out.print(ret);
+        if (debug) {
+            if      (ret==null) return null;
+            else if (ret==left)  System.out.print("\033[31m{\033[0m");
+            else if (ret==right) System.out.print("\033[31m}\033[0m");
+            else System.out.print(ret);
+        }
         return ret;
     }