sjm.parse
Class Repetition
java.lang.Object
|
+--sjm.parse.Parser
|
+--sjm.parse.Repetition
- Direct Known Subclasses:
- VerboseRepetition
- public class Repetition
- extends Parser
A Repetition matches its underlying parser
repeatedly against a assembly.
|
Constructor Summary |
Repetition(Parser p)
Constructs a repetition of the given parser. |
Repetition(Parser subparser,
java.lang.String name)
Constructs a repetition of the given parser with the
given name. |
|
Method Summary |
void |
accept(ParserVisitor pv,
java.util.Vector visited)
Accept a "visitor" and a collection of previously visited
parsers. |
Parser |
getSubparser()
Return this parser's subparser. |
java.util.Vector |
match(java.util.Vector in)
Given a set of assemblies, this method applies a preassembler
to all of them, matches its subparser repeatedly against each
of them, applies its post-assembler against each, and returns
a new set of the assemblies that result from the matches. |
protected java.util.Vector |
randomExpansion(int maxDepth,
int depth)
Create a collection of random elements that correspond to
this repetition. |
Parser |
setPreAssembler(Assembler preAssembler)
Sets the object that will work on every assembly before
matching against it. |
protected java.lang.String |
unvisitedString(java.util.Vector visited)
|
| 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 |
subparser
protected Parser subparser
EXPWIDTH
protected static final int EXPWIDTH
preAssembler
protected Assembler preAssembler
Repetition
public Repetition(Parser p)
- Constructs a repetition of the given parser.
- Parameters:
parser - the parser to repeat
Repetition
public Repetition(Parser subparser,
java.lang.String name)
- Constructs a repetition of the given parser with the
given name.
- Parameters:
Parser - the parser to repeatString - a name to be known by
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 acceptVector - a collection of previously visited parsers
getSubparser
public Parser getSubparser()
- Return this parser's subparser.
- Returns:
- Parser this parser's subparser
match
public java.util.Vector match(java.util.Vector in)
- Given a set of assemblies, this method applies a preassembler
to all of them, matches its subparser repeatedly against each
of them, applies its post-assembler against each, and returns
a new set of the assemblies that result from the matches.
For example, matching the regular expression a*
against {^aaab} results in
{^aaab, a^aab, aa^ab, aaa^b}.
- 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)
- Create a collection of random elements that correspond to
this repetition.
- Overrides:
- randomExpansion in class Parser
setPreAssembler
public Parser setPreAssembler(Assembler preAssembler)
- Sets the object that will work on every assembly before
matching against it.
- Parameters:
Assembler - the assembler to apply- Returns:
- Parser this
unvisitedString
protected java.lang.String unvisitedString(java.util.Vector visited)
- Overrides:
- unvisitedString in class Parser