From 6a2ea790f843e058c7e67d3c7d1deebadcfe1fd5 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 15 Jan 2006 05:59:30 -0500 Subject: [PATCH 1/1] checkpoint darcs-hash:20060115105930-5007d-6df5f9158f1d2637d73f600779fd7915ef75dbf3.gz --- src/edu/berkeley/sbp/Atom.java | 14 ++------------ src/edu/berkeley/sbp/Forest.java | 14 +++++++------- src/edu/berkeley/sbp/GSS.java | 6 +++--- src/edu/berkeley/sbp/{Token.java => Input.java} | 2 +- src/edu/berkeley/sbp/ParseFailed.java | 6 +++--- src/edu/berkeley/sbp/Parser.java | 6 +++--- src/edu/berkeley/sbp/Sequence.java | 14 +++++++------- src/edu/berkeley/sbp/Tree.java | 8 ++++---- src/edu/berkeley/sbp/Walk.java | 10 +++++----- .../CharToStringParser.java => chr/CharParser.java} | 9 +++++---- src/edu/berkeley/sbp/{misc => chr}/CharRange.java | 5 +++-- src/edu/berkeley/sbp/{misc => chr}/CharTopology.java | 3 ++- src/edu/berkeley/sbp/misc/CartesianInput.java | 12 ++++++------ src/edu/berkeley/sbp/misc/MetaGrammar.java | 14 ++++++++++++-- src/edu/berkeley/sbp/misc/RegressionTests.java | 11 ++++++----- src/edu/berkeley/sbp/misc/StringToken.java | 4 ++-- src/edu/berkeley/sbp/tib/Tib.java | 5 +++-- src/edu/berkeley/sbp/tib/TibDoc.java | 7 +++---- 18 files changed, 77 insertions(+), 73 deletions(-) rename src/edu/berkeley/sbp/{Token.java => Input.java} (97%) rename src/edu/berkeley/sbp/{misc/CharToStringParser.java => chr/CharParser.java} (87%) rename src/edu/berkeley/sbp/{misc => chr}/CharRange.java (94%) rename src/edu/berkeley/sbp/{misc => chr}/CharTopology.java (95%) diff --git a/src/edu/berkeley/sbp/Atom.java b/src/edu/berkeley/sbp/Atom.java index 03383ab..cb7a379 100644 --- a/src/edu/berkeley/sbp/Atom.java +++ b/src/edu/berkeley/sbp/Atom.java @@ -31,28 +31,18 @@ public abstract class Atom extends Element implements Topology { // Subclasses ////////////////////////////////////////////////////////////////////////////// - public static class Infer extends Atom { + public static class Infer extends Atom { private final Element e; public Infer(Element e) { this.e = e; } public Topology top() { return (Topology)e.toAtom(); } public String toString() { return e.toString(); /* FIXME should be toAtom() */ } } - public static class Invert extends Atom { + public static class Invert extends Atom { private final Atom a; public Invert(Atom a) { this.a = a; } public Topology top() { return ((Topology)a.top()).complement(); } public String toString() { return "~"+a; } } - - public static class Hack extends Atom { - private final Atom a; - static final Topology leftright = - edu.berkeley.sbp.misc.CharRange.rightBrace.union(edu.berkeley.sbp.misc.CharRange.leftBrace); - public Hack(Atom a) { this.a = a; } - public Topology top() { return ((Topology)a.top()).minus(leftright); } - public String toString() { return "~"+a; } - } - } diff --git a/src/edu/berkeley/sbp/Forest.java b/src/edu/berkeley/sbp/Forest.java index 917fea5..e4572ec 100644 --- a/src/edu/berkeley/sbp/Forest.java +++ b/src/edu/berkeley/sbp/Forest.java @@ -19,10 +19,10 @@ public abstract class Forest { /** expand this forest into a set of trees */ public abstract HashSet> expand(boolean toss); - static Forest singleton(Token.Location loc) { return create(loc, null, new Forest[] { }, false, true); } - static Forest singleton(Token.Location loc, Forest body) { return create(loc, null, new Forest[] { body }, false, true); } - static Forest leaf(Token.Location loc, T tag) { return create(loc, tag, null, false, false); } - public static Forest create(Token.Location loc, T tag, Forest[] tokens, boolean unwrap, boolean singleton) { + static Forest singleton(Input.Location loc) { return create(loc, null, new Forest[] { }, false, true); } + static Forest singleton(Input.Location loc, Forest body) { return create(loc, null, new Forest[] { body }, false, true); } + static Forest leaf(Input.Location loc, T tag) { return create(loc, tag, null, false, false); } + public static Forest create(Input.Location loc, T tag, Forest[] tokens, boolean unwrap, boolean singleton) { return new MultiForest(loc, tag, tokens, unwrap, singleton); } @@ -30,13 +30,13 @@ public abstract class Forest { protected static class Body { - private final Token.Location location; + private final Input.Location location; private final T tag; private final Forest[] tokens; private final boolean unwrap; private final boolean singleton; - private Body(Token.Location loc, T tag, Forest[] tokens, boolean unwrap, boolean singleton) { + private Body(Input.Location loc, T tag, Forest[] tokens, boolean unwrap, boolean singleton) { this.location = loc; this.tag = tag; this.tokens = tokens==null ? emptyForestArray : new Forest[tokens.length]; @@ -134,7 +134,7 @@ public abstract class Forest { private static class MultiForest extends IterableForest { private final FastSet> results; private MultiForest(FastSet> results) { this.results = results; } - public MultiForest(Token.Location loc, T tag, Forest[] tokens, boolean unwrap, boolean singleton) { + public MultiForest(Input.Location loc, T tag, Forest[] tokens, boolean unwrap, boolean singleton) { this.results = new FastSet>(new Body(loc, tag, tokens, unwrap, singleton)); } public Iterator> iterator() { return results.iterator(); } diff --git a/src/edu/berkeley/sbp/GSS.java b/src/edu/berkeley/sbp/GSS.java index d25593f..bd2ecd6 100644 --- a/src/edu/berkeley/sbp/GSS.java +++ b/src/edu/berkeley/sbp/GSS.java @@ -43,12 +43,12 @@ class GSS { private boolean good; private Phase next = null; private Phase prev; - private Token.Location location; + private Input.Location location; public final Parser parser; private Forest forest; - public Phase(Phase prev, Parser parser, Phase previous, Tok token, Token.Location location, Forest forest) { + public Phase(Phase prev, Parser parser, Phase previous, Tok token, Input.Location location, Forest forest) { this.prev = prev; this.forest = forest; this.parser = parser; @@ -81,7 +81,7 @@ class GSS { return true; } - public Token.Location getLocation() { return location; } + public Input.Location getLocation() { return location; } /** add a new node (merging with existing nodes if possible) * @param parent the parent of the new node diff --git a/src/edu/berkeley/sbp/Token.java b/src/edu/berkeley/sbp/Input.java similarity index 97% rename from src/edu/berkeley/sbp/Token.java rename to src/edu/berkeley/sbp/Input.java index a662e8a..b326468 100644 --- a/src/edu/berkeley/sbp/Token.java +++ b/src/edu/berkeley/sbp/Input.java @@ -7,7 +7,7 @@ import edu.berkeley.sbp.*; import edu.berkeley.sbp.util.*; /** a token of input -- note that this represents an actual input token rather than an Element which matches a token */ -public interface Token { +public interface Input { /** this is declared abstract as a way of forcing subclasses to provide a thoughtful implementation */ public abstract String toString(); diff --git a/src/edu/berkeley/sbp/ParseFailed.java b/src/edu/berkeley/sbp/ParseFailed.java index 9c0a3ad..75baf3a 100644 --- a/src/edu/berkeley/sbp/ParseFailed.java +++ b/src/edu/berkeley/sbp/ParseFailed.java @@ -9,11 +9,11 @@ import java.util.*; /** thrown when the parser arrives at a state from which it is clear that no valid parse can result */ public class ParseFailed extends RuntimeException { - private final Token.Location location; + private final Input.Location location; private final String message; public ParseFailed() { this("", null); } - public ParseFailed(String message, Token.Location loc) { this.location = loc; this.message = message; } - public Token.Location getLocation() { return location; } + public ParseFailed(String message, Input.Location loc) { this.location = loc; this.message = message; } + public Input.Location getLocation() { return location; } public String toString() { return message/* + (location==null ? "" : (" at " + location))*/; } public static void complain(GSS.Phase.Node n, HashMap> errors, boolean force) { diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 60da9e4..87b5508 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -15,12 +15,12 @@ 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(Tok t, Token.Location loc); + public abstract Forest shiftToken(Tok t, Input.Location loc); /** parse input, using the table pt to drive the parser */ - public Forest parse(Token.Stream input) throws IOException, ParseFailed { + public Forest parse(Input.Stream input) throws IOException, ParseFailed { GSS gss = new GSS(); - Token.Location loc = input.getLocation(); + Input.Location loc = input.getLocation(); GSS.Phase current = gss.new Phase(null, this, null, input.next(1, 0, 0), loc, null); current.newNode(null, Forest.leaf(null, null), pt.start, true); int count = 1; diff --git a/src/edu/berkeley/sbp/Sequence.java b/src/edu/berkeley/sbp/Sequence.java index ac34264..b31b307 100644 --- a/src/edu/berkeley/sbp/Sequence.java +++ b/src/edu/berkeley/sbp/Sequence.java @@ -81,7 +81,7 @@ public abstract class Sequence extends Element implements Iterable { return epsilonForm; } - protected abstract Forest postReduce(Token.Location loc, Forest[] args); + protected abstract Forest postReduce(Input.Location loc, Forest[] args); // Position ////////////////////////////////////////////////////////////////////////////// @@ -123,12 +123,12 @@ public abstract class Sequence extends Element implements Iterable { // Position ///////////////////////////////////////////////////////////////////////////////// - final Forest rewrite(Token.Location loc) { + final Forest rewrite(Input.Location loc) { if (this==firstp()) return epsilonForm(); return rewrite2(loc); } - final Forest rewrite2(Token.Location loc) { + final Forest rewrite2(Input.Location loc) { for(int i=0; i { static class Constant extends Sequence { private final Object result; public Constant(Element[] e, Object result, HashSet and, HashSet not) { super(e, and, not); this.result = result; } - public Forest postReduce(Token.Location loc, Forest[] args) { + public Forest postReduce(Input.Location loc, Forest[] args) { return (Forest)Forest.leaf(loc, result); } static class Drop extends Constant { @@ -190,14 +190,14 @@ public abstract class Sequence extends Element implements Iterable { private final int idx; public Singleton(Element e, HashSet and, HashSet not) { this(new Element[] { e }, 0, and, not); } public Singleton(Element[] e, int idx, HashSet and, HashSet not) { super(e, and, not); this.idx = idx; } - public Forest postReduce(Token.Location loc, Forest[] args) { return (Forest)Forest.singleton(loc, args[idx]); } + public Forest postReduce(Input.Location loc, Forest[] args) { return (Forest)Forest.singleton(loc, args[idx]); } } public static class Unwrap extends Sequence { private boolean[] drops; public Unwrap(Element[] e, HashSet and, HashSet not) { super(e, and, not); this.drops = null; } public Unwrap(Element[] e, boolean[] drops, HashSet and, HashSet not) { super(e, and, not); this.drops = drops; } - public Forest postReduce(Token.Location loc, Forest[] args) { + public Forest postReduce(Input.Location loc, Forest[] args) { for(int i=0; i { this.drops = drops == null ? new boolean[e.length] : drops; for(int i=0; i Forest postReduce(Token.Location loc, Forest[] args) { + public Forest postReduce(Input.Location loc, Forest[] args) { Forest[] args2 = new Forest[count]; int j = 0; for(int i=0; i extends PrintableTree> implements Iterable> final T head; Tree[] children; - final Token.Location location; + final Input.Location location; public T head() { return head; } public int numChildren() { return children.length; } @@ -19,10 +19,10 @@ public class Tree extends PrintableTree> implements Iterable> public Iterator> iterator() { return new ArrayIterator(children); } public Tree child(int i) { return children[i]; } - public Token.Location getLocation() { return location; } + public Input.Location getLocation() { return location; } - public Tree(Token.Location loc, T head) { this(loc, head, null); } - public Tree(Token.Location loc, T head, Tree[] children) { + public Tree(Input.Location loc, T head) { this(loc, head, null); } + public Tree(Input.Location loc, T head, Tree[] children) { this.location = loc; this.head = head; Tree[] children2 = children==null ? new Tree[0] : new Tree[children.length]; diff --git a/src/edu/berkeley/sbp/Walk.java b/src/edu/berkeley/sbp/Walk.java index 380d09b..04e36ae 100644 --- a/src/edu/berkeley/sbp/Walk.java +++ b/src/edu/berkeley/sbp/Walk.java @@ -75,9 +75,9 @@ abstract class Walk { } - // Token-Set ////////////////////////////////////////////////////////////////////////////// + // Input-Set ////////////////////////////////////////////////////////////////////////////// - static abstract class WalkTokenSet extends Walk> { + static abstract class WalkTokenSet extends Walk> { public Topology cs; public WalkTokenSet(Topology cs) { this.cs = cs; } public WalkTokenSet(Topology cs, Cache c) { super(c); this.cs = cs; } @@ -85,7 +85,7 @@ abstract class Walk { public Topology walkAtom(Atom r) { cs = cs.union(r); return cs; } } - static class First extends WalkTokenSet { + static class First extends WalkTokenSet { public First(Topology cs, Walk.Cache cache) { super(cs, cache); } public Topology sequence(Sequence seq) { for(Position p = seq.firstp(); p!=null && !p.isLast(); p = p.next()) { @@ -96,7 +96,7 @@ abstract class Walk { } } - static class Follow extends WalkTokenSet { + static class Follow extends WalkTokenSet { private final Element me; private final HashSet all; private boolean eof = false; @@ -172,7 +172,7 @@ abstract class Walk { public HashMap follow = new HashMap(); public HashMapBag ys = new HashMapBag(); public HashMap atoms = new HashMap(); - public Topology first(Element e, Topology empty) { + public Topology first(Element e, Topology empty) { return new Walk.First(empty, this).walk(e); } } diff --git a/src/edu/berkeley/sbp/misc/CharToStringParser.java b/src/edu/berkeley/sbp/chr/CharParser.java similarity index 87% rename from src/edu/berkeley/sbp/misc/CharToStringParser.java rename to src/edu/berkeley/sbp/chr/CharParser.java index 1153e51..db235cd 100644 --- a/src/edu/berkeley/sbp/misc/CharToStringParser.java +++ b/src/edu/berkeley/sbp/chr/CharParser.java @@ -1,13 +1,14 @@ -package edu.berkeley.sbp.misc; +package edu.berkeley.sbp.chr; import java.io.*; import java.util.*; import java.lang.reflect.*; import java.lang.ref.*; import edu.berkeley.sbp.*; -import edu.berkeley.sbp.Token.Location; import edu.berkeley.sbp.util.*; +import edu.berkeley.sbp.misc.*; +import edu.berkeley.sbp.Input.Location; -public class CharToStringParser extends Parser { +public class CharParser extends Parser { public Forest parse(InputStream is) throws IOException, ParseFailed { return super.parse(new Stream(is)); } @@ -15,7 +16,7 @@ public class CharToStringParser extends Parser { return super.parse(new Stream(r)); } - public CharToStringParser(Union u) { + public CharParser(Union u) { super(u, new CharTopology()); pt.optimize(new CharTopology()); } diff --git a/src/edu/berkeley/sbp/misc/CharRange.java b/src/edu/berkeley/sbp/chr/CharRange.java similarity index 94% rename from src/edu/berkeley/sbp/misc/CharRange.java rename to src/edu/berkeley/sbp/chr/CharRange.java index 4fd319d..cac3bbb 100644 --- a/src/edu/berkeley/sbp/misc/CharRange.java +++ b/src/edu/berkeley/sbp/chr/CharRange.java @@ -1,11 +1,12 @@ -package edu.berkeley.sbp.misc; +package edu.berkeley.sbp.chr; import java.io.*; import java.util.*; import java.lang.reflect.*; import java.lang.ref.*; import edu.berkeley.sbp.*; -import edu.berkeley.sbp.Token.Location; import edu.berkeley.sbp.util.*; +import edu.berkeley.sbp.misc.*; +import edu.berkeley.sbp.Input.Location; public class CharRange extends Atom { diff --git a/src/edu/berkeley/sbp/misc/CharTopology.java b/src/edu/berkeley/sbp/chr/CharTopology.java similarity index 95% rename from src/edu/berkeley/sbp/misc/CharTopology.java rename to src/edu/berkeley/sbp/chr/CharTopology.java index 81ab840..3a065d1 100644 --- a/src/edu/berkeley/sbp/misc/CharTopology.java +++ b/src/edu/berkeley/sbp/chr/CharTopology.java @@ -1,5 +1,6 @@ -package edu.berkeley.sbp.misc; +package edu.berkeley.sbp.chr; import edu.berkeley.sbp.*; +import edu.berkeley.sbp.misc.*; import edu.berkeley.sbp.util.*; public class CharTopology extends IntegerTopology implements Functor { diff --git a/src/edu/berkeley/sbp/misc/CartesianInput.java b/src/edu/berkeley/sbp/misc/CartesianInput.java index cf477cc..200396e 100644 --- a/src/edu/berkeley/sbp/misc/CartesianInput.java +++ b/src/edu/berkeley/sbp/misc/CartesianInput.java @@ -4,10 +4,10 @@ import java.util.*; import java.lang.reflect.*; import java.lang.ref.*; import edu.berkeley.sbp.*; -import edu.berkeley.sbp.Token.Location; +import edu.berkeley.sbp.Input.Location; import edu.berkeley.sbp.util.*; -public abstract class CartesianInput implements Token.Stream { +public abstract class CartesianInput implements Input.Stream { private int line = 1; private int col = 0; @@ -16,8 +16,8 @@ public abstract class CartesianInput implements Token.Stream { public abstract boolean isCR(); long then = 0; - private Token.Location location = new LocWrap(line, col); - public Token.Location getLocation() { return location; } + private Input.Location location = new LocWrap(line, col); + public Input.Location getLocation() { return location; } public Tok next(int numstates, int resets, int waits) throws IOException { Tok t = next(); if (t==null) return null; @@ -39,14 +39,14 @@ public abstract class CartesianInput implements Token.Stream { return t; } - public static class Location implements Token.Location { + public static class Location implements Input.Location { public final int line; public final int col; public String toString() { return line + ":" + col; } public Location(int line, int col) { this.line = line; this.col = col; } } - private class LocWrap implements Token.Location { + private class LocWrap implements Input.Location { public final int line; public final int col; public String toString() { return line + ":" + col; } diff --git a/src/edu/berkeley/sbp/misc/MetaGrammar.java b/src/edu/berkeley/sbp/misc/MetaGrammar.java index 4b5f707..03f8f97 100644 --- a/src/edu/berkeley/sbp/misc/MetaGrammar.java +++ b/src/edu/berkeley/sbp/misc/MetaGrammar.java @@ -1,11 +1,21 @@ package edu.berkeley.sbp.misc; import edu.berkeley.sbp.util.*; import edu.berkeley.sbp.*; +import edu.berkeley.sbp.chr.*; import java.util.*; import java.io.*; public class MetaGrammar extends StringWalker { + public static class Hack extends Atom { + private final Atom a; + static final Topology leftright = CharRange.rightBrace.union(CharRange.leftBrace); + public Hack(Atom a) { this.a = a; } + public Topology top() { return a.minus(leftright); } + public String toString() { return "~"+a; } + } + + public static Union make() throws Exception { return ((MetaGrammar)new MetaGrammar().walk(meta)).done(); } @@ -123,7 +133,7 @@ public class MetaGrammar extends StringWalker { else if ("psylr".equals(head)) throw new Error("not supported"); else if ("/".equals(head)) return ((PreSequence)walk(tree, 0)).sparse((Element)walk(tree, 1)); else if ("~".equals(head)) - return new Atom.Hack(new Atom.Invert(new Atom.Infer((Element)walk(tree, 0)))); + return new Hack(new Atom.Invert(new Atom.Infer((Element)walk(tree, 0)))); else if ("ps".equals(head)) return new PreSequence((Element[])walk(tree, 0)); else if ("ps".equals(head)) return new PreSequence((Element[])walk(tree, 0)); else if ("qprod".equals(head)) { @@ -278,7 +288,7 @@ public class MetaGrammar extends StringWalker { } out.append("\n // DO NOT EDIT STUFF BELOW: IT IS AUTOMATICALLY GENERATED\n"); - new CharToStringParser(MetaGrammar.make()).parse(new FileInputStream(args[0])).expand1().toJava(out); + new CharParser(MetaGrammar.make()).parse(new FileInputStream(args[0])).expand1().toJava(out); out.append("\n // DO NOT EDIT STUFF ABOVE: IT IS AUTOMATICALLY GENERATED\n"); for(String s = br.readLine(); s != null; s = br.readLine()) out.append(s+"\n"); diff --git a/src/edu/berkeley/sbp/misc/RegressionTests.java b/src/edu/berkeley/sbp/misc/RegressionTests.java index af92d0b..cf0b4e3 100644 --- a/src/edu/berkeley/sbp/misc/RegressionTests.java +++ b/src/edu/berkeley/sbp/misc/RegressionTests.java @@ -4,6 +4,7 @@ import java.util.*; import edu.berkeley.sbp.*; import edu.berkeley.sbp.misc.*; import edu.berkeley.sbp.tib.*; +import edu.berkeley.sbp.chr.*; public class RegressionTests { @@ -22,15 +23,15 @@ public class RegressionTests { //MetaGrammar mg0 = new MetaGrammar(); //mg0.walk(MetaGrammar.meta); //System.out.println(mg0); - Tree res = new CharToStringParser(MetaGrammar.make()).parse(new FileInputStream(s[0])).expand1(); + Tree res = new CharParser(MetaGrammar.make()).parse(new FileInputStream(s[0])).expand1(); MetaGrammar mg = (MetaGrammar)new MetaGrammar().walk(res); //System.out.println(mg); Union meta = mg.done(); SequenceInputStream sis = new SequenceInputStream(new FileInputStream(s[0]), new FileInputStream(s[1])); - res = new CharToStringParser(meta).parse(sis).expand1(); + res = new CharParser(meta).parse(sis).expand1(); Union testcasegrammar = ((MetaGrammar)new MetaGrammar("ts").walk(res)).done("ts"); if (testcasegrammar==null) return; - CharToStringParser parser = new CharToStringParser(testcasegrammar); + CharParser parser = new CharParser(testcasegrammar); if (profile) { System.out.println("\nready..."); @@ -79,8 +80,8 @@ public class RegressionTests { ParseFailed pfe = null; try { res = tib - ? /*new CharToStringParser(grammar).parse(new Tib(input))*/ null - : new CharToStringParser(grammar).parse(new StringReader(input)); + ? /*new CharParser(grammar).parse(new Tib(input))*/ null + : new CharParser(grammar).parse(new StringReader(input)); } catch (ParseFailed pf) { pfe = pf; } diff --git a/src/edu/berkeley/sbp/misc/StringToken.java b/src/edu/berkeley/sbp/misc/StringToken.java index bab4eff..b21e458 100644 --- a/src/edu/berkeley/sbp/misc/StringToken.java +++ b/src/edu/berkeley/sbp/misc/StringToken.java @@ -8,8 +8,8 @@ import edu.berkeley.sbp.*; import edu.berkeley.sbp.util.*; import edu.berkeley.sbp.*; -/** an implementation of Token for streams of Java char values */ -public class StringToken implements Token { +/** an implementation of Input for streams of Java char values */ +public class StringToken implements Input { public static final StringToken left = new StringToken(null, null) { public boolean equals(Object o) { return this==o; } }; public static final StringToken right = new StringToken(null, null) { public boolean equals(Object o) { return this==o; } }; diff --git a/src/edu/berkeley/sbp/tib/Tib.java b/src/edu/berkeley/sbp/tib/Tib.java index 4b4a247..15c286a 100644 --- a/src/edu/berkeley/sbp/tib/Tib.java +++ b/src/edu/berkeley/sbp/tib/Tib.java @@ -5,6 +5,7 @@ package edu.berkeley.sbp.tib; import edu.berkeley.sbp.*; import edu.berkeley.sbp.misc.*; +import edu.berkeley.sbp.chr.*; import java.util.*; import java.io.*; @@ -23,7 +24,7 @@ import java.io.*; * experimentation with the TIB spec. Once the spec is finalized it * should probably be rewritten. */ -public class Tib implements Token.Stream { +public class Tib implements Input.Stream { public Tib(String s) throws IOException { this(new StringReader(s)); } public Tib(Reader r) throws IOException { this(new BufferedReader(r)); } @@ -41,7 +42,7 @@ public class Tib implements Token.Stream { int _row = 1; int _col = 0; - public Token.Location getLocation() { return new CartesianInput.Location(_row, _col); } + public Input.Location getLocation() { return new CartesianInput.Location(_row, _col); } private BufferedReader br; char left = CharRange.left; diff --git a/src/edu/berkeley/sbp/tib/TibDoc.java b/src/edu/berkeley/sbp/tib/TibDoc.java index 2883508..553397b 100644 --- a/src/edu/berkeley/sbp/tib/TibDoc.java +++ b/src/edu/berkeley/sbp/tib/TibDoc.java @@ -3,11 +3,10 @@ // You may not use this file except in compliance with the License. package edu.berkeley.sbp.tib; -//import org.ibex.util.*; -//import org.ibex.io.*; import edu.berkeley.sbp.*; import edu.berkeley.sbp.misc.*; import edu.berkeley.sbp.util.*; +import edu.berkeley.sbp.chr.*; import java.util.*; import java.io.*; @@ -15,13 +14,13 @@ public class TibDoc { public static void main(String[] s) throws Exception { System.out.println("parsing " + s[0]); - Tree res = new CharToStringParser(MetaGrammar.make()).parse(new FileInputStream(s[0])).expand1(); + Tree res = new CharParser(MetaGrammar.make()).parse(new FileInputStream(s[0])).expand1(); MetaGrammar gram = (MetaGrammar)new Tib.Grammar().walk(res); //System.out.println(gram); Union mg = gram.done(); System.out.println("\nparsing " + s[1]); - Forest f = new CharToStringParser(mg).parse(new Tib(new FileInputStream(s[1]))); + Forest f = new CharParser(mg).parse(new Tib(new FileInputStream(s[1]))); System.out.println(); System.out.println(f); -- 1.7.10.4