From: adam Date: Fri, 31 Mar 2006 14:54:44 +0000 (-0500) Subject: checkpoint X-Git-Tag: tag_for_25-Mar~270 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=e12a3098c6ed3cbfa6493870af3688f833c4f8ac checkpoint darcs-hash:20060331145444-5007d-81652a11544c90538e753530c79d1755dc03a8ae.gz --- diff --git a/src/edu/berkeley/sbp/Input.java b/src/edu/berkeley/sbp/Input.java index be41cbe..846fd9a 100644 --- a/src/edu/berkeley/sbp/Input.java +++ b/src/edu/berkeley/sbp/Input.java @@ -18,25 +18,6 @@ public interface Input { /** a location between tokens in the input stream */ public static interface Location extends Comparable { public String toString(); - - /** an implementation of Location for a cartesian grid (row, col) */ - public static class Cartesian implements Location, Comparable { - protected final int row; - protected final int col; - public String toString() { return row+":"+col; } - public int getCol() { return col; } - public int getRow() { return row; } - public Cartesian(int col, int row) { this.row = row; this.col = col; } - public int compareTo(Location loc) throws ClassCastException { - if (!(loc instanceof Cartesian)) throw new ClassCastException(); - Cartesian c = (Cartesian)loc; - if (row < c.row) return -1; - if (row > c.row) return 1; - if (col < c.col) return -1; - if (col > c.col) return 1; - return 0; - } - } } public static class Region /* implements Topology> */ { diff --git a/src/edu/berkeley/sbp/chr/CharInput.java b/src/edu/berkeley/sbp/chr/CharInput.java index 1178e42..7953418 100644 --- a/src/edu/berkeley/sbp/chr/CharInput.java +++ b/src/edu/berkeley/sbp/chr/CharInput.java @@ -8,7 +8,7 @@ import edu.berkeley.sbp.util.*; import edu.berkeley.sbp.misc.*; import edu.berkeley.sbp.Input.Location; -public class CharInput extends CartesianInput { +public class CharInput extends Cartesian.Input { private final Reader r; public CharInput(String s) { this(new StringReader(s)); } diff --git a/src/edu/berkeley/sbp/misc/CartesianInput.java b/src/edu/berkeley/sbp/misc/CartesianInput.java deleted file mode 100644 index 3af71f1..0000000 --- a/src/edu/berkeley/sbp/misc/CartesianInput.java +++ /dev/null @@ -1,41 +0,0 @@ -package edu.berkeley.sbp.misc; -import java.io.*; -import java.util.*; -import java.lang.reflect.*; -import java.lang.ref.*; -import edu.berkeley.sbp.*; -import edu.berkeley.sbp.Input.Location; -import edu.berkeley.sbp.util.*; - -public abstract class CartesianInput implements Input { - - public abstract Token next() throws IOException; - public abstract boolean isCR(); - - long then = 0; - private Input.Location.Cartesian location = new Input.Location.Cartesian(0, 1); - public Input.Location getLocation() { return location; } - - public Token next(int numstates, int resets, int waits) throws IOException { - int line = location.getRow(); - int col = location.getCol(); - Token t = next(); - if (t==null) return null; - String s = " line "+line+", col " + col; - while(s.length() < 20) s += " "; - s += "[ambiguity level: " + (numstates-1) + "] [resets: " + resets + "] [waits: " + waits + "]"; - long now = System.currentTimeMillis(); - if (now-then > 10) { - then = now; - System.out.print(s + " \r"); - } - if (isCR()) { - line++; - col = 1; - } else { - col++; - } - location = new Input.Location.Cartesian(col, line); - return t; - } -} diff --git a/src/edu/berkeley/sbp/misc/MetaGrammar.java b/src/edu/berkeley/sbp/misc/MetaGrammar.java index 59b6a21..7dda407 100644 --- a/src/edu/berkeley/sbp/misc/MetaGrammar.java +++ b/src/edu/berkeley/sbp/misc/MetaGrammar.java @@ -529,6 +529,7 @@ public class MetaGrammar extends StringWalker { + // DO NOT EDIT STUFF BELOW: IT IS AUTOMATICALLY GENERATED new edu.berkeley.sbp.Tree(null, "grammar", new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, null, new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, "=", new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, null, new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, "s", new edu.berkeley.sbp.Tree[] { })}), new edu.berkeley.sbp.Tree(null, null, new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, null, new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, "psx", new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, "ps", new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, null, new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, "!", new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, "nonTerminal", new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, null, new edu.berkeley.sbp.Tree[] { new edu.berkeley.sbp.Tree(null, "w", new edu.berkeley.sbp.Tree[] { }), @@ -1192,3 +1193,4 @@ new edu.berkeley.sbp.Tree(null, "grammar", new edu.berkeley.sbp.Tree[] { new edu + diff --git a/src/edu/berkeley/sbp/tib/Tib.java b/src/edu/berkeley/sbp/tib/Tib.java index 4805d1e..1492240 100644 --- a/src/edu/berkeley/sbp/tib/Tib.java +++ b/src/edu/berkeley/sbp/tib/Tib.java @@ -42,7 +42,7 @@ public class Tib implements Input { int _row = 1; int _col = 0; - public Input.Location getLocation() { return new Input.Location.Cartesian(_col, _row); } + public Input.Location getLocation() { return new Cartesian.Location(_col, _row); } private BufferedReader br; char left = CharRange.left;