sjm.parse.tokens
Class Symbol

java.lang.Object
  |
  +--sjm.parse.Parser
        |
        +--sjm.parse.Terminal
              |
              +--sjm.parse.tokens.Symbol

public class Symbol
extends Terminal

A Symbol matches a specific sequence, such as <, or <= that a tokenizer returns as a symbol.

Version:
1.0
Author:
Steven J. Metsker

Field Summary
protected  Token symbol
          the literal to match
 
Fields inherited from class sjm.parse.Terminal
discard
 
Fields inherited from class sjm.parse.Parser
assembler, name
 
Constructor Summary
Symbol(char c)
          Constructs a symbol that will match the specified char.
Symbol(java.lang.String s)
          Constructs a symbol that will match the specified sequence of characters.
 
Method Summary
protected  boolean qualifies(java.lang.Object o)
          Returns true if the symbol this object represents equals an assembly's next element.
 java.lang.String unvisitedString(java.util.Vector visited)
          Returns a textual description of this parser.
 
Methods inherited from class sjm.parse.Terminal
accept, discard, match, matchOneAssembly, randomExpansion, 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
 

Field Detail

symbol

protected Token symbol
the literal to match
Constructor Detail

Symbol

public Symbol(char c)
Constructs a symbol that will match the specified char.
Parameters:
char - the character to match. The char must be one that the tokenizer will return as a symbol token. This typically includes most characters except letters and digits.

Symbol

public Symbol(java.lang.String s)
Constructs a symbol that will match the specified sequence of characters.
Parameters:
String - the characters to match. The characters must be a sequence that the tokenizer will return as a symbol token, such as <=.
Method Detail

qualifies

protected boolean qualifies(java.lang.Object o)
Returns true if the symbol this object represents equals an assembly's next element.
Overrides:
qualifies in class Terminal
Parameters:
object - an element from an assembly
Returns:
true, if the specified symbol equals the next token from an assembly

unvisitedString

public java.lang.String unvisitedString(java.util.Vector visited)
Returns a textual description of this parser.
Overrides:
unvisitedString in class Terminal
Parameters:
vector - a list of parsers already printed in this description
Returns:
string a textual description of this parser
See Also:
Parser.toString()