Building Parsers with Java

sjm.examples.mechanics
Class LowercaseWord

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

public class LowercaseWord
extends Word

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


Fields inherited from class sjm.parse.Terminal
discard
 
Fields inherited from class sjm.parse.Parser
assembler, name
 
Constructor Summary
LowercaseWord()
           
 
Method Summary
protected  boolean qualifies(java.lang.Object o)
          Returns true if an assembly's next element is a lower case word.
 java.util.Vector randomExpansion(int maxDepth, int depth)
          Create a set with one random 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

LowercaseWord

public LowercaseWord()
Method Detail

qualifies

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

randomExpansion

public java.util.Vector randomExpansion(int maxDepth,
                                        int depth)
Description copied from class: Word
Create a set with one random 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