From: adam Date: Mon, 26 Mar 2007 05:38:21 +0000 (-0400) Subject: add Input.getName() X-Git-Tag: tag_for_25-Mar~23 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=dcf8aafe73cbd899d8aebd2ef92df5a75a2c2b69 add Input.getName() darcs-hash:20070326053821-5007d-c207384172db213a6ffcd955e0c71cdead8ea431.gz --- diff --git a/src/edu/berkeley/sbp/Input.java b/src/edu/berkeley/sbp/Input.java index 6e4b0ee..13c45d4 100644 --- a/src/edu/berkeley/sbp/Input.java +++ b/src/edu/berkeley/sbp/Input.java @@ -16,6 +16,9 @@ public interface Input { /** returns the location the input stream is currently at */ public Location getLocation(); + + /** should return a short string describing where the input is coming from */ + public String getName(); /** * Optional: If possible, this method will return a diff --git a/src/edu/berkeley/sbp/chr/CharInput.java b/src/edu/berkeley/sbp/chr/CharInput.java index 2e8e882..a03f940 100644 --- a/src/edu/berkeley/sbp/chr/CharInput.java +++ b/src/edu/berkeley/sbp/chr/CharInput.java @@ -59,17 +59,23 @@ public class CharInput extends Cartesian.Input { private final RollbackReader r; - public CharInput(String s) { this(new StringReader(s)); } - public CharInput(Reader r) { this(r, null); } - public CharInput(Reader r, String s) { this.r = new RollbackReader(new BufferedReader(r)); } - public CharInput(InputStream i) { this(i, null); } - public CharInput(InputStream i, String s) { this(new InputStreamReader(i), s); } + public CharInput(Reader r, String s) { + this.name = s; + this.r = new RollbackReader(new BufferedReader(r)); + } + public CharInput(String s) { this(new StringReader(s)); } + public CharInput(Reader r) { this(r, null); } + public CharInput(InputStream i) { this(i, null); } + public CharInput(InputStream i, String s) { this(new InputStreamReader(i), s); } + public CharInput(File f) throws IOException { this(new FileInputStream(f), f.getName()); } public CharInput(InputStream i, String s, boolean indent) { this(new InputStreamReader(i), s); this.indent = indent; } + public String getName() { return name; } + private String name; boolean cr = false; boolean indent = false; private int count = 0; diff --git a/src/edu/berkeley/sbp/tib/Tib.java b/src/edu/berkeley/sbp/tib/Tib.java index c2f3468..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. * @@ -35,7 +31,7 @@ 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;