-// Copyright 2005 the Contributors, as shown in the revision logs.
-// Licensed under the Apache Public Source License 2.0 ("the License").
-// You may not use this file except in compliance with the License.
+// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license
package edu.berkeley.sbp.tib;
import edu.berkeley.sbp.*;
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.
*
*/
public class Tib implements Input<Character> {
+ 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)); }
public Tib(InputStream is) throws IOException { this(new BufferedReader(new InputStreamReader(is))); }
//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;
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;
}
return null;
}
c = (char)i;
+ _scalar++;
if (c=='\n') { _row++; _col=0; }
else _col++;
}