sjm.parse
Class Alternation

java.lang.Object
  |
  +--sjm.parse.Parser
        |
        +--sjm.parse.CollectionParser
              |
              +--sjm.parse.Alternation

public class Alternation
extends CollectionParser

An Alternation object is a collection of parsers, any one of which can successfully match against an assembly.

Version:
1.0
Author:
Steven J. Metsker

Fields inherited from class sjm.parse.CollectionParser
subparsers
 
Fields inherited from class sjm.parse.Parser
assembler, name
 
Constructor Summary
Alternation()
          Constructs a nameless alternation.
Alternation(java.lang.String name)
          Constructs an alternation with the given name.
 
Method Summary
 void accept(ParserVisitor pv, java.util.Vector visited)
          Accept a "visitor" and a collection of previously visited parsers.
 java.util.Vector match(java.util.Vector in)
          Given a set of assemblies, this method matches this alternation against all of them, and returns a new set of the assemblies that result from the matches.
protected  java.util.Vector randomExpansion(int maxDepth, int depth)
           
protected  java.util.Vector randomSettle(int maxDepth, int depth)
           
protected  java.lang.String toStringSeparator()
          Helps to textually describe this CollectionParser.
 
Methods inherited from class sjm.parse.CollectionParser
add, getSubparsers, unvisitedString
 
Methods inherited from class sjm.parse.Parser
accept, add, best, bestMatch, completeMatch, elementClone, getName, matchAndAssemble, randomInput, setAssembler, toString, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Alternation

public Alternation()
Constructs a nameless alternation.

Alternation

public Alternation(java.lang.String name)
Constructs an alternation with the given name.
Parameters:
name - a name to be known by
Method Detail

accept

public void accept(ParserVisitor pv,
                   java.util.Vector visited)
Accept a "visitor" and a collection of previously visited parsers.
Overrides:
accept in class Parser
Parameters:
ParserVisitor - the visitor to accept
Vector - a collection of previously visited parsers

match

public java.util.Vector match(java.util.Vector in)
Given a set of assemblies, this method matches this alternation against all of them, and returns a new set of the assemblies that result from the matches.
Overrides:
match in class Parser
Parameters:
Vector - a vector of assemblies to match against
Returns:
a Vector of assemblies that result from matching against a beginning set of assemblies

randomExpansion

protected java.util.Vector randomExpansion(int maxDepth,
                                           int depth)
Overrides:
randomExpansion in class Parser

randomSettle

protected java.util.Vector randomSettle(int maxDepth,
                                        int depth)

toStringSeparator

protected java.lang.String toStringSeparator()
Description copied from class: CollectionParser
Helps to textually describe this CollectionParser.
Overrides:
toStringSeparator in class CollectionParser