From: adam Date: Wed, 11 Jan 2006 07:48:02 +0000 (-0500) Subject: checkpoint harmony X-Git-Tag: tag_for_25-Mar~395 X-Git-Url: http://git.megacz.com/?p=sbp.git;a=commitdiff_plain;h=2fa0e673bf1813cce48ae7004e533a317d5f58e0 checkpoint harmony darcs-hash:20060111074802-5007d-8d18df8a7b99acfa3017c1a4d59243b55443100c.gz --- diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 0d04f3f..d04c49f 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -11,15 +11,12 @@ public abstract class Parser { private final Table pt; /** create a parser to parse the grammar with start symbol u */ - protected Parser(Union u) { this.pt = new Table(u, top()); } - protected Parser(Table pt) { this.pt = pt; } + protected Parser(Union u, Topology top) { this.pt = new Table(u, top); } + 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 shiftedToken(T t, Token.Location loc); - /** this method must return an empty topology of the input token type */ - public abstract Topology top(); - /** parse input, using the table pt to drive the parser */ public Forest parse(Token.Stream input) throws IOException, ParseFailed { GSS gss = new GSS(); @@ -244,11 +241,8 @@ public abstract class Parser { } } - private static final Forest[] emptyForestArray = new Forest[0]; - - // Helpers ////////////////////////////////////////////////////////////////////////////// - + private static void reachable(Element e, HashSet h) { if (e instanceof Atom) return; for(Sequence s : ((Union)e)) diff --git a/src/edu/berkeley/sbp/misc/CharToken.java b/src/edu/berkeley/sbp/misc/CharToken.java index 0793d80..87be340 100644 --- a/src/edu/berkeley/sbp/misc/CharToken.java +++ b/src/edu/berkeley/sbp/misc/CharToken.java @@ -14,8 +14,7 @@ public class CharToken implements Token, IntegerMappable { // Public ////////////////////////////////////////////////////////////////////////////// public static class CharToStringParser extends Parser { - public CharToStringParser(Union u) { super(u); } - public Topology top() { return new IntegerTopology(); } + public CharToStringParser(Union u) { super(u, new IntegerTopology()); } public Forest shiftedToken(CharToken ct, Token.Location loc) { return Forest.create(loc, ct.result(), null, false, false); }