_____________________________________________________________________________
Immediately
- - needs/hates/follow API ugliness
-
- Topology crap is kinda messed up
- Atom should be a topology, shouldn't it?
+ - needs/hates/follow API ugliness
+
- do Forest/Tree still need a Region?
- reconsider the degree of genericization
- GraphViz stuff pollutes the API...
import edu.berkeley.sbp.*;
import edu.berkeley.sbp.*;
-/** an element which matches exactly one input token */
+/** <font color=green>an element which matches exactly one input token</font> */
public abstract class Atom<T> extends Element implements Topology<T> {
protected abstract Topology<T> top();
import java.lang.reflect.*;
import java.lang.ref.*;
-/** the root superclass for all components of the grammar (terminals, nonterminals, literals, etc) */
+/** <font color=green>the root superclass for all components of the grammar (terminals, nonterminals, literals, etc)</font> */
public abstract class Element {
/** sorry, you can't make up new, custom elements */
import java.lang.reflect.*;
/**
+ * <font color=blue>
* An efficient representation of a collection of trees (Tomita's
* shared packed parse forest).
+ * </font>
*/
public abstract class Forest<T> implements GraphViz.ToGraphViz {
import edu.berkeley.sbp.*;
import edu.berkeley.sbp.util.*;
-/** a stream of tokens to be parsed */
+/** <font color=purple>a stream of <tt>Token</tt>s to be parsed</font> */
public interface Input<Token> {
/** returns the token just beyond the current location and advances beyond it */
/** returns the location the input stream is currently at */
public Location<Token> getLocation();
- /** a location <i>between tokens<i> in the input stream */
- public static interface Location<Tok> extends Comparable<Location> {
+ /** <font color=purple>a location (position) in the input stream -- <i>between tokens</i></font> */
+ public static interface Location<Token> extends Comparable<Location> {
+
+ /** return the region between this location and <tt>loc</tt> */
+ public Region<Token> createRegion(Location<Token> loc);
+
public String toString();
- public Region<Tok> createRegion(Location<Tok> loc);
}
- public static interface Region<Tok> /* implements Topology<Location<Tok>> */ { }
+ /** <font color=purple>a contiguous set of <tt>Location</tt>s</font> */
+ public static interface Region<Token> /* implements Topology<Location<Tok>> */ {
+ }
+
}
import java.lang.reflect.*;
import java.lang.ref.*;
-/** juxtaposition; zero or more adjacent Elements; can specify a rewriting */
+/** <font color=green>juxtaposition; zero or more adjacent Elements; can specify a rewriting</font> */
public abstract class Sequence extends Element implements Iterable<Element> {
+ protected final Element[] elements;
+
+ final HashSet<Sequence> hated = new HashSet<Sequence>();
+
+ final HashSet<Sequence> needs = new HashSet<Sequence>();
+ final HashSet<Sequence> hates = new HashSet<Sequence>();
+
+ final Position firstp;
+
+ public Atom follow = null;
+ public final Topology follow() { return follow; }
+
// Static Constructors //////////////////////////////////////////////////////////////////////////////
abstract Sequence _clone();
Sequence dup() {
Sequence ret = _clone();
- for(Sequence s : needs) { ret.needs.add(s); s.needed.add(ret); }
+ for(Sequence s : needs) { ret.needs.add(s); }
for(Sequence s : hates) { ret.hates.add(s); s.hated.add(ret); }
ret.follow = follow;
return ret;
////////////////////////////////////////////////////////////////////////////////
- public Atom follow = null;
- public final Topology follow() { return follow; }
-
- public Sequence and(Sequence s) { Sequence ret = dup(); ret.needs.add(s); s.needed.add(ret); return ret; }
+ public Sequence and(Sequence s) { Sequence ret = dup(); ret.needs.add(s); return ret; }
public Sequence not(Sequence s) { Sequence ret = dup(); ret.hates.add(s); s.hated.add(ret); return ret; }
public Iterable<Sequence> needs() { return needs; }
public Iterable<Sequence> hates() { return hates; }
- protected final Element[] elements;
-
- final HashSet<Sequence> needed = new HashSet<Sequence>();
- final HashSet<Sequence> hated = new HashSet<Sequence>();
- final HashSet<Sequence> needs = new HashSet<Sequence>();
- final HashSet<Sequence> hates = new HashSet<Sequence>();
-
- final Position firstp;
Position firstp() { return firstp; }
public Iterator<Element> iterator() { return new ArrayIterator<Element>(elements); }
import java.util.*;
import java.lang.reflect.*;
-/** a tree (or node in a tree); see jargon.txt for details */
+/** <font color=blue>a tree (or node in a tree); see jargon.txt for details</font> */
public class Tree<T>
extends PrintableTree<Tree<T>>
implements Iterable<Tree<T>>,
import java.lang.reflect.*;
import java.lang.ref.*;
-/** an element which can produce one of several alternatives */
+/** <font color=green>an element which can produce one of several alternatives</font> */
public class Union extends Element implements Iterable<Sequence> {
private final String name;
<body>
-<b><font color=red>IMPORTANT:</font> BE SURE TO READ THE FILE <tt><font size=big><a href=../../../../jargon.txt>doc/jargon.txt</a></big></tt> FIRST!</b>
+<p>
+<b>
+ <font color=red>IMPORTANT:</font>
+ BE SURE TO READ THE FILE
+ <tt><font size=big><a href=../../../../jargon.txt>doc/jargon.txt</a></big></tt> FIRST!<br> Also, see the legend at the bottom of this page.
+</b>
+</p>
+
+<p>
+This package forms the stable core of the SBP API Classes fall into
+five categories:
+
+<ul> <li> <font color=green>Elements of the grammar</font> -- the
+ pieces from which a grammar is composed.
+
+ <li> <font color=purple>Input, Location, and Region</font> -- the
+ input to be parsed, as well as classes for describing
+ locations and regions of that input.
+
+ <li> Parser -- the engine that actually performs the parsing
+ process.
+
+ <li> <font color=blue>Trees and Forests</font> -- used to
+ represent the output of the parsing process.
+
+ <li> Exceptions.
+</ul>
+</p>
+
</body>