Building Parsers with Java

sjm.examples.sling
Class ReservedLiteral

java.lang.Object
  |
  +--sjm.parse.Parser
        |
        +--sjm.parse.Terminal
              |
              +--sjm.examples.sling.ReservedLiteral

public class ReservedLiteral
extends Terminal

A ReservedLiteral matches a specific string that a tokenizer returns as a reserved word type.


Field Summary
protected  Token literal
          the literal to match
 
Fields inherited from class sjm.parse.Terminal
discard
 
Fields inherited from class sjm.parse.Parser
assembler, name
 
Constructor Summary
ReservedLiteral(java.lang.String s)
          Constructs a reserved literal that will match the specified string as a reserved word.
 
Method Summary
protected  boolean qualifies(java.lang.Object o)
          Returns true if the literal this object equals a 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

literal

protected Token literal
the literal to match
Constructor Detail

ReservedLiteral

public ReservedLiteral(java.lang.String s)
Constructs a reserved literal that will match the specified string as a reserved word.
Parameters:
string - the string to match as a token
Method Detail

qualifies

protected boolean qualifies(java.lang.Object o)
Returns true if the literal this object equals a assembly's next element.
Overrides:
qualifies in class Terminal
Parameters:
Object - an element from an assembly
Returns:
true, if the specified literal 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:
a textual description of this parser

by Steve Metsker