X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2Ftib%2FTib.java;h=41aab5cd869fdd8e4e0322916664170670bc02f6;hp=2398c5cf2fd72ff221e08c0ff5f7bb9ececc7bf4;hb=dcf8aafe73cbd899d8aebd2ef92df5a75a2c2b69;hpb=3ee451bce342d4bb61ad6235ba57bdf817bfdd1a diff --git a/src/edu/berkeley/sbp/tib/Tib.java b/src/edu/berkeley/sbp/tib/Tib.java index 2398c5c..41aab5c 100644 --- a/src/edu/berkeley/sbp/tib/Tib.java +++ b/src/edu/berkeley/sbp/tib/Tib.java @@ -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,6 +20,8 @@ import java.io.*; */ public class Tib implements Input { + public String showRegion(Region r) { return ""; } + public Tib(String s) throws IOException { this(new StringReader(s)); } public Tib(Reader r) throws IOException { this(new BufferedReader(r)); } public Tib(InputStream is) throws IOException { this(new BufferedReader(new InputStreamReader(is))); } @@ -33,14 +31,15 @@ public class Tib implements Input { //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; int _row = 1; int _col = 0; - public Input.Location getLocation() { return new Cartesian.Location(_col, _row); } + int _scalar = 0; + public Input.Location getLocation() { return new Cartesian.Location(_col, _row, _scalar); } private BufferedReader br; char left = CharAtom.left; @@ -51,12 +50,15 @@ public class Tib implements Input { boolean indenting = true; int indentation = 0; private ArrayList istack = new ArrayList(); + 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; } @@ -81,6 +83,7 @@ public class Tib implements Input { return null; } c = (char)i; + _scalar++; if (c=='\n') { _row++; _col=0; } else _col++; }