Building Parsers with Java

sjm.examples.mechanics
Class UppercaseWord

java.lang.Object
  |
  +--sjm.parse.Parser
        |
        +--sjm.parse.Terminal
              |
              +--sjm.parse.tokens.Word
                    |
                    +--sjm.examples.mechanics.UppercaseWord

public class UppercaseWord
extends Word

This class shows the how to introduce a new type of terminal, specifically for recognizing uppercase words.


Fields inherited from class sjm.parse.Terminal
discard
 
Fields inherited from class sjm.parse.Parser
assembler, name
 
Constructor Summary
UppercaseWord()
           
 
Method Summary
protected  boolean qualifies(java.lang.Object o)
          Returns true if an assembly's next element is an upper case word.
 java.util.Vector randomExpansion(int maxDepth, int depth)
          Create a set with one random uppercase word (with 3 to 7 characters).
 java.lang.String unvisitedString(java.util.Vector visited)
          Returns a textual description of this production.
 
Methods inherited from class sjm.parse.Terminal
accept, discard, match, matchOneAssembly, setDiscard
 
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

UppercaseWord

public UppercaseWord()
Method Detail

qualifies

protected boolean qualifies(java.lang.Object o)
Returns true if an assembly's next element is an upper case word.
Overrides:
qualifies in class Word
Parameters:
object - an element from a assembly
Returns:
true, if a assembly's next element is an upper case word

randomExpansion

public java.util.Vector randomExpansion(int maxDepth,
                                        int depth)
Create a set with one random uppercase word (with 3 to 7 characters).
Overrides:
randomExpansion in class Word

unvisitedString

public java.lang.String unvisitedString(java.util.Vector visited)
Returns a textual description of this production.
Overrides:
unvisitedString in class Word
Parameters:
vector - a list of productions already printed in this description
Returns:
string a textual description of this production
See Also:
ProductionRule#toString()

by Steve Metsker