checkpoint
authoradam <adam@megacz.com>
Sun, 6 Aug 2006 03:21:04 +0000 (23:21 -0400)
committeradam <adam@megacz.com>
Sun, 6 Aug 2006 03:21:04 +0000 (23:21 -0400)
darcs-hash:20060806032104-5007d-f6d8dc8cda56c82e5c06b436e4a9e34412a5f565.gz

TODO
src/edu/berkeley/sbp/Walk.java
src/edu/berkeley/sbp/chr/CharInput.java

diff --git a/TODO b/TODO
index 280f875..e3e7dfa 100644 (file)
--- a/TODO
+++ b/TODO
@@ -6,8 +6,6 @@ Immediately
 
   - Annotation Tutorial
 
 
   - Annotation Tutorial
 
-  - Get at least *some* sort of moderate improvement in the error messages
-
   ..................................................
 
   - evil problems with: (x y? z /ws)
   ..................................................
 
   - evil problems with: (x y? z /ws)
index 092d1ff..5e1f534 100644 (file)
@@ -109,7 +109,8 @@ abstract class Walk<T> {
         private final HashSet<SequenceOrElement> all;
         private boolean eof = false;
         public boolean includesEof() { return eof; }
         private final HashSet<SequenceOrElement> all;
         private boolean eof = false;
         public boolean includesEof() { return eof; }
-        public Follow(Topology<Tok> cs, SequenceOrElement me, HashSet<SequenceOrElement> all, Cache c)  { super(cs, c); this.me = me; this.all = all; }
+        public Follow(Topology<Tok> cs, SequenceOrElement me, HashSet<SequenceOrElement> all, Cache c)  {
+          super(cs, c); this.me = me; this.all = all; }
         public Topology<Tok> bottom(SequenceOrElement e)                       { return cs; }
         public Topology<Tok> sequence(Sequence seq)                  { return cs; }
         public Topology<Tok> walkAtom(Atom r) { return walk((SequenceOrElement)r); }
         public Topology<Tok> bottom(SequenceOrElement e)                       { return cs; }
         public Topology<Tok> sequence(Sequence seq)                  { return cs; }
         public Topology<Tok> walkAtom(Atom r) { return walk((SequenceOrElement)r); }
index b6a175d..15f1289 100644 (file)
@@ -52,11 +52,19 @@ public class CharInput extends Cartesian.Input<Character> {
         if (end < start) end = start;
         if (end > cache.length()) end = cache.length();
         String ret;
         if (end < start) end = start;
         if (end > cache.length()) end = cache.length();
         String ret;
-        if (end-start < 60) ret = cache.substring(start, end);
-        else ret = cache.substring(start, start+25) +
+        if (end-start < 60) ret = cachesubstring(start, end);
+        else ret = cachesubstring(start, start+25) +
                  "..." +
                  "..." +
-                 cache.substring(end-25, end);
+                 cachesubstring(end-25, end);
         return StringUtil.escapify(ret, "\n\r");
     }
 
         return StringUtil.escapify(ret, "\n\r");
     }
 
+    private String cachesubstring(int start, int end) {
+        if (start < 0) start = 0;
+        if (end < 0)   end = 0;
+        if (start >= cache.length()) start = cache.length();
+        if (end >= cache.length()) end = cache.length();
+        return cache.substring(start, end);
+    }
+
 }
 }