edu.iu.cnets.klatsch.parser
Class Token

java.lang.Object
  extended by edu.iu.cnets.klatsch.parser.Token

 class Token
extends java.lang.Object

This class represents a single token within the Klatsch language.


Nested Class Summary
static class Token.Type
           
 
Field Summary
(package private) static java.lang.String[] KEYWORDS
          any strings defined here are automatically recognized as language keywords
(package private)  Token.Type type
           
(package private)  java.lang.Object value
           
 
Constructor Summary
Token(Token.Type type)
          Initializes a new token of a type that does not take a value.
Token(Token.Type type, java.lang.Object value)
          Initializes a new token of a type that does take a value.
 
Method Summary
(package private)  boolean isKeyword(java.lang.String keyword)
          Determine whether this token is a keyword of the given type.
(package private)  boolean isType(Token.Type type)
          Determine whether this token is of the given type.
(package private)  double numberValue()
          Returns the numeric value of the token.
(package private)  java.lang.String stringValue()
          Returns the string value of the token.
(package private)  java.lang.String toDebugString()
          Renders this token as a debugging string that identifies the type of the token.
 java.lang.String toString()
          Renders this token as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEYWORDS

static final java.lang.String[] KEYWORDS
any strings defined here are automatically recognized as language keywords


type

Token.Type type

value

java.lang.Object value
Constructor Detail

Token

Token(Token.Type type)
Initializes a new token of a type that does not take a value.

Parameters:
type - the type of the token

Token

public Token(Token.Type type,
             java.lang.Object value)
Initializes a new token of a type that does take a value.

Parameters:
type - the type of the token
value - the value of the token
Method Detail

numberValue

double numberValue()
Returns the numeric value of the token.

Returns:
the floating-point value

isKeyword

boolean isKeyword(java.lang.String keyword)
Determine whether this token is a keyword of the given type.

Parameters:
keyword - the keyword to check
Returns:
true on a match, false otherwise

isType

boolean isType(Token.Type type)
Determine whether this token is of the given type.

Parameters:
type - the type to check
Returns:
true on a match, false otherwise

stringValue

java.lang.String stringValue()
Returns the string value of the token.

Returns:
the string value

toDebugString

java.lang.String toDebugString()
Renders this token as a debugging string that identifies the type of the token.

Returns:
the token represented as a string

toString

public java.lang.String toString()
Renders this token as a string.

Overrides:
toString in class java.lang.Object
Returns:
the token represented as a string