From 280e93a7eec101178dc81f8009eedb2916271f09 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 16 Jul 2006 03:53:41 -0400 Subject: [PATCH 1/1] checkpoint darcs-hash:20060716075341-5007d-f5dffd8569ffb25d2fdf4677916ddc8203a031f1.gz --- TODO | 2 ++ src/edu/berkeley/sbp/Forest.java | 3 +-- src/edu/berkeley/sbp/GSS.java | 14 +++++++------- src/edu/berkeley/sbp/Parser.java | 4 ++-- src/edu/berkeley/sbp/Tree.java | 1 - src/edu/berkeley/sbp/Union.java | 18 +++++++++--------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/TODO b/TODO index 7186baf..d58eb06 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,8 @@ _____________________________________________________________________________ Immediately - do Forest/Tree still need a Region? + - reconsider the degree of genericization + - GraphViz stuff pollutes the API... - Forest needs a "manual access" API - the unwrap bit in Forest makes it really hard to expose an API for forests diff --git a/src/edu/berkeley/sbp/Forest.java b/src/edu/berkeley/sbp/Forest.java index 645850b..bd3b46a 100644 --- a/src/edu/berkeley/sbp/Forest.java +++ b/src/edu/berkeley/sbp/Forest.java @@ -27,10 +27,9 @@ public abstract class Forest implements GraphViz.ToGraphViz { abstract void expand(HashSet> ht, HashSet> ignore, Tree bogus); abstract void gather(HashSet> ignore); + abstract void edges(GraphViz.Node n); boolean ambiguous() { return false; } - public abstract void edges(GraphViz.Node n); - // One ////////////////////////////////////////////////////////////////////////////// diff --git a/src/edu/berkeley/sbp/GSS.java b/src/edu/berkeley/sbp/GSS.java index f85ec0b..9075f41 100644 --- a/src/edu/berkeley/sbp/GSS.java +++ b/src/edu/berkeley/sbp/GSS.java @@ -8,17 +8,17 @@ import java.util.*; import java.lang.reflect.*; /** implements Tomita's Graph Structured Stack */ -public class GSS { +class GSS { - public static int count = 0; - public static int shifts = 0; - public static int reductions = 0; + static int count = 0; + static int shifts = 0; + static int reductions = 0; + int resets = 0; + int waits = 0; public GSS() { } private Phase.Node[] reducing_list = null; - public int resets = 0; - public int waits = 0; // FIXME: right now, these are the performance bottleneck HashMapBag waiting = new HashMapBag(); @@ -27,7 +27,7 @@ public class GSS { HashMapBag expected = new HashMapBag(); /** FIXME */ - public Forest.Many finalResult; + Forest.Many finalResult; /** corresponds to a positions between tokens the input stream; same as Tomita's U_i's */ class Phase implements Invokable.Node>, IntegerMappable, GraphViz.ToGraphViz, Iterable { diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 300ff27..744b7c0 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -15,9 +15,9 @@ public abstract class Parser { protected Parser(Table pt) { this.pt = pt; } /** implement this method to create the output forest corresponding to a lone shifted input token */ - public abstract Forest shiftToken(Input.Location oldloc, Tok t, Input.Location newloc); + protected abstract Forest shiftToken(Input.Location oldloc, Tok t, Input.Location newloc); - public boolean helpgc = true; + boolean helpgc = true; public String toString() { return pt.toString(); } diff --git a/src/edu/berkeley/sbp/Tree.java b/src/edu/berkeley/sbp/Tree.java index 2f72029..2bfd187 100644 --- a/src/edu/berkeley/sbp/Tree.java +++ b/src/edu/berkeley/sbp/Tree.java @@ -92,5 +92,4 @@ public class Tree public boolean isTransparent() { return false; } public boolean isHidden() { return false; } - } diff --git a/src/edu/berkeley/sbp/Union.java b/src/edu/berkeley/sbp/Union.java index 6cba89c..99ef42b 100644 --- a/src/edu/berkeley/sbp/Union.java +++ b/src/edu/berkeley/sbp/Union.java @@ -10,6 +10,10 @@ import java.lang.ref.*; /** an element which can produce one of several alternatives */ public class Union extends Element implements Iterable { + private final String name; + private final boolean synthetic; + private final List alternatives = new ArrayList(); + /** * Since every cycle in a non-degenerate grammar contains at * least one Union, every instance of this class must be able to @@ -20,16 +24,12 @@ public class Union extends Element implements Iterable { * @param synthetic if true, this Union's "long form" is "obvious" and should not be displayed when printing the grammar */ public Union() { this(null, false); } - public Union(String shortForm) { this(shortForm, false); } - public Union(String shortForm, boolean synthetic) { - this.shortForm = shortForm; + public Union(String name) { this(name, false); } + public Union(String name, boolean synthetic) { + this.name = name; this.synthetic = synthetic; } - final String shortForm; - final boolean synthetic; - private final List alternatives = new ArrayList(); - public Iterator iterator() { return alternatives.iterator(); } public boolean contains(Sequence s) { return alternatives.contains(s); } @@ -64,11 +64,11 @@ public class Union extends Element implements Iterable { // Display ////////////////////////////////////////////////////////////////////////////// public String getName() { - if (shortForm != null) return shortForm; + if (name != null) return name; return "(anon_union)"; } public String toString() { - if (shortForm != null) return shortForm; + if (name != null) return name; StringBuffer sb = new StringBuffer(); sb.append("("); bodyToString(sb, "", " | "); -- 1.7.10.4