org.codehaus.groovy.syntax
Class Token

java.lang.Object
  extended byorg.codehaus.groovy.syntax.Token

public class Token
extends java.lang.Object

Lexical token.

Version:
$Id: Token.java,v 1.27 2004/03/07 12:18:54 jstrachan Exp $
Author:
bob mcwhirter

Field Summary
static int COLON
          Token type for ":".
static int COMMA
           
static int COMPARE_EQUAL
          Token type for ":=".
static int COMPARE_GREATER_THAN
          Token type for ">".
static int COMPARE_GREATER_THAN_EQUAL
          Token type for ">=".
static int COMPARE_IDENTICAL
          Token type for "==".
static int COMPARE_LESS_THAN
          Token type for "<".
static int COMPARE_LESS_THAN_EQUAL
          Token type for "<=".
static int COMPARE_NOT_EQUAL
          Token type for "!=".
static int COMPARE_TO
          Token type for "<=>".
static int DIVIDE
          Token type for "/".
static int DIVIDE_EQUAL
          Token type for "/=".
static int DOT
          Token type for ".".
static int DOT_DOT
          Token type for "..".
static int DOT_DOT_DOT
          Token type for "...".
static int DOUBLE_QUOTE_STRING
          Token type for double-quoted string literal.
static int EQUAL
          Token type for "=".
static int FIND_REGEX
          Token type for "~=".
static int FLOAT_NUMBER
          Token type for floating-point number.
static int IDENTIFIER
          Token type for identifier.
static int INTEGER_NUMBER
          Token type for integral number.
static int KEYWORD_ABSTRACT
           
static int KEYWORD_AS
           
static int KEYWORD_ASSERT
           
static int KEYWORD_BOOLEAN
           
static int KEYWORD_BREAK
           
static int KEYWORD_BYTE
           
static int KEYWORD_CASE
           
static int KEYWORD_CATCH
           
static int KEYWORD_CHAR
           
static int KEYWORD_CLASS
           
static int KEYWORD_CONST
           
static int KEYWORD_CONTINUE
           
static int KEYWORD_DEF
           
static int KEYWORD_DEFAULT
           
static int KEYWORD_DO
           
static int KEYWORD_DOUBLE
           
static int KEYWORD_ELSE
           
static int KEYWORD_EXTENDS
           
static int KEYWORD_FALSE
           
static int KEYWORD_FINAL
           
static int KEYWORD_FINALLY
           
static int KEYWORD_FLOAT
           
static int KEYWORD_FOR
           
static int KEYWORD_GOTO
           
static int KEYWORD_IF
           
static int KEYWORD_IMPLEMENTS
           
static int KEYWORD_IMPORT
           
static int KEYWORD_IN
           
static int KEYWORD_INSTANCEOF
           
static int KEYWORD_INT
           
static int KEYWORD_INTERFACE
           
static int KEYWORD_LONG
           
static int KEYWORD_NATIVE
           
static int KEYWORD_NEW
           
static int KEYWORD_NULL
           
static int KEYWORD_PACKAGE
           
static int KEYWORD_PRIVATE
           
static int KEYWORD_PROPERTY
           
static int KEYWORD_PROTECTED
           
static int KEYWORD_PUBLIC
           
static int KEYWORD_RETURN
           
static int KEYWORD_SHORT
           
static int KEYWORD_STATIC
           
static int KEYWORD_SUPER
           
static int KEYWORD_SWITCH
           
static int KEYWORD_SYNCHRONIZED
           
static int KEYWORD_THIS
           
static int KEYWORD_THROW
           
static int KEYWORD_THROWS
           
static int KEYWORD_TRANSIENT
           
static int KEYWORD_TRUE
           
static int KEYWORD_TRY
           
static int KEYWORD_VOID
           
static int KEYWORD_VOLATILE
           
static int KEYWORD_WHILE
           
static int LEFT_CURLY_BRACE
          Token type for "{".
static int LEFT_PARENTHESIS
          Token type for "(".
static int LEFT_SHIFT
          Token type for "<<".
static int LEFT_SQUARE_BRACKET
          Token type for "[".
static int LOGICAL_AND
          Token type for "&&".
static int LOGICAL_OR
          Token type for "||".
static int MATCH_REGEX
          Token type for "~==".
static int MINUS
          Token type for "-".
static int MINUS_EQUAL
          Token type for "-=".
static int MINUS_MINUS
          Token type for "--".
static int MOD
          Token type for "%".
static int MOD_EQUAL
          Token type for "%=".
static int MULTIPLY
          Token type for "*".
static int MULTIPLY_EQUAL
          Token type for "*=".
static int NAVIGATE
          Token type for "->".
static int NEWLINE
          Token type for "\n".
static int NOT
          Token type for "!".
static int PATTERN_REGEX
          Token type for "~"
static int PIPE
          Token type for "|".
static int PLUS
          Token type for "+".
static int PLUS_EQUAL
          Token type for "+=".
static int PLUS_PLUS
          Token type for "++".
static int QUESTION
          Token type for "?".
static int RIGHT_CURLY_BRACE
          Token type for "}".
static int RIGHT_PARENTHESIS
          Token type for ")".
static int RIGHT_SHIFT
          Token type for ">>".
static int RIGHT_SQUARE_BRACKET
          Token type for "]".
static int SEMICOLON
          Token type for ";".
static int SINGLE_QUOTE_STRING
          Token type for single-quoted string literal.
static int SYNTH_BLOCK
           
static int SYNTH_CAST
           
static int SYNTH_CLOSURE
           
static int SYNTH_LABEL
           
static int SYNTH_LIST
           
static int SYNTH_MAP
           
static int SYNTH_METHOD
           
static int SYNTH_PARAMETER_DECLARATION
           
static int SYNTH_POSTFIX
           
static int SYNTH_PREFIX
           
 
Constructor Summary
protected Token(int type, java.lang.String text, int startLine, int startColumn)
          Construct.
 
Method Summary
static Token colon(int startLine, int startColumn)
          Factory method for token for ":".
static Token comma(int startLine, int startColumn)
           
static Token compareEqual(int startLine, int startColumn)
          Factory method for token for ":=".
static Token compareGreaterThan(int startLine, int startColumn)
          Factory method for token for ">".
static Token compareGreaterThanEqual(int startLine, int startColumn)
          Factory method for token for ">=".
static Token compareIdentical(int startLine, int startColumn)
          Factory method for token for "==".
static Token compareLessThan(int startLine, int startColumn)
          Factory method for token for "<".
static Token compareLessThanEqual(int startLine, int startColumn)
          Factory method for token for "<=".
static Token compareNotEqual(int startLine, int startColumn)
          Factory method for token for "!=".
static Token compareTo(int startLine, int startColumn)
          Factory method for token for "<=>".
static Token divide(int startLine, int startColumn)
          Factory method for token for "/".
static Token divideEqual(int startLine, int startColumn)
          Factory method for token for "/=".
static Token dot(int startLine, int startColumn)
          Factory method for token for ".".
static Token dotDot(int startLine, int startColumn)
           
static Token dotDotDot(int startLine, int startColumn)
           
static Token doubleQuoteString(int startLine, int startColumn, java.lang.String text)
          Factory method for token for double-quoted string.
static Token equal(int startLine, int startColumn)
          Factory method for token for "=".
static Token findRegex(int startLine, int startColumn)
          Factory method for token for "~=".
static Token floatNumber(int startLine, int startColumn, java.lang.String text)
           
 java.lang.String getDescription()
           
 int getInterpretation()
          Retrieve the interpretation (usually, but not always, the same as type.
static java.util.Map getKeywordMap()
           
 int getStartColumn()
          Retrieve the starting column within the source.
 int getStartLine()
          Retrieve the starting line within the source.
 java.lang.String getText()
          Retrieve the actual token text.
static java.lang.String getTokenDescription(int type)
           
 int getType()
          Retrieve the type.
static Token identifier(int startLine, int startColumn, java.lang.String text)
          Factory method for token for identifier.
static Token integerNumber(int startLine, int startColumn, java.lang.String text)
           
 boolean isA(int type)
          Returns true if this token is of the specified type.
 boolean isA(int[] types)
          Returns true if this token is of any of the specified types.
 boolean isAssignmentToken()
          Returns true if this token performs an assignment to the LHS such as = or += or *= etc.
static boolean isAssignmentToken(int type)
          Returns true if this token performs an assignment to the LHS such as = or += or *= etc.
 boolean isIdentifierOrPrimitiveTypeKeyword()
          Returns true if the token is an identifier or a primitive type.
static boolean isIdentifierOrPrimitiveTypeKeyword(int type)
          Returns true if the specified type is an identifier or a primitive type.
 boolean isModifier()
          Returns true if the token is a class modifier.
static boolean isModifier(int type)
          Returns true if the specified token type is a class modifier.
 boolean isPrimitiveTypeKeyword(boolean evenVoid)
          Returns true if the token is a primitive type.
static boolean isPrimitiveTypeKeyword(int type, boolean evenVoid)
          Returns true if the token type is a primitive type.
 boolean isValidNameReference()
          Returns true if the token is a valid as a name that has already been declared.
static boolean isValidNameReference(int type)
          Returns true if the specified type is valid as a reference to an existing name.
static Token keyword(int startLine, int startColumn, java.lang.String text)
           
static Token leftCurlyBrace(int startLine, int startColumn)
          Factory method for token for "{".
static Token leftParenthesis(int startLine, int startColumn)
          Factory method for token for "(".
static Token leftShift(int startLine, int startColumn)
          Factory method for token for "<<".
static Token leftSquareBracket(int startLine, int startColumn)
          Factory method for token for "[".
static Token logicalAnd(int startLine, int startColumn)
          Factory method for token for "&&".
static Token logicalOr(int startLine, int startColumn)
          Factory method for token for "||".
static Token matchRegex(int startLine, int startColumn)
          Factory method for token for "~==".
static Token minus(int startLine, int startColumn)
          Factory method for token for "-".
static Token minusEqual(int startLine, int startColumn)
          Factory method for token for "-=".
static Token minusMinus(int startLine, int startColumn)
          Factory method for token for "--".
static Token mod(int startLine, int startColumn)
          Factory method for token for "%".
static Token modEqual(int startLine, int startColumn)
          Factory method for token for "%=".
static Token multiply(int startLine, int startColumn)
          Factory method for token for "*".
static Token multiplyEqual(int startLine, int startColumn)
          Factory method for token for "*=".
static Token navigate(int startLine, int startColumn)
          Factory method for token for "->".
static Token newline(int startLine, int startColumn)
          Factory method for token for "\n".
static Token newToken(int type, int startLine, int startColumn)
          Creates the token of the given id
protected static Token newToken(int type, java.lang.String text, int startLine, int startColumn)
          Generic factory method for a token.
static Token not(int startLine, int startColumn)
          Factory method for token for "!".
static boolean ofType(int type, int[] types)
          Returns true if specified token type is in the supplied list.
static Token patternRegex(int startLine, int startColumn)
          Factory method for token for double-quoted string.
static Token pipe(int startLine, int startColumn)
          Factory method for token for "|".
static Token plus(int startLine, int startColumn)
          Factory method for token for "+".
static Token plusEqual(int startLine, int startColumn)
          Factory method for token for "+=".
static Token plusPlus(int startLine, int startColumn)
          Factory method for token for "++".
static Token question(int startLine, int startColumn)
          Factory method for token for "?".
static Token rightCurlyBrace(int startLine, int startColumn)
          Factory method for token for "}".
static Token rightParenthesis(int startLine, int startColumn)
          Factory method for token for ")".
static Token rightShift(int startLine, int startColumn)
          Factory method for token for ">>".
static Token rightSquareBracket(int startLine, int startColumn)
          Factory method for token for "]".
static Token semicolon(int startLine, int startColumn)
          Factory method for token for ";".
 void setInterpretation(int type)
          Sets an interpretation for the token.
static Token singleQuoteString(int startLine, int startColumn, java.lang.String text)
          Factory method for token for single-quoted string.
static Token syntheticBlock()
           
static Token syntheticCast()
           
static Token syntheticClosure()
           
static Token syntheticList()
           
static Token syntheticMap()
           
static Token syntheticMethod()
           
static Token syntheticParameterDeclaration()
           
static Token syntheticPostfix()
           
static Token syntheticPrefix()
           
 Token toIdentifier()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NEWLINE

public static final int NEWLINE
Token type for "\n".

See Also:
Constant Field Values

LEFT_CURLY_BRACE

public static final int LEFT_CURLY_BRACE
Token type for "{".

See Also:
Constant Field Values

RIGHT_CURLY_BRACE

public static final int RIGHT_CURLY_BRACE
Token type for "}".

See Also:
Constant Field Values

LEFT_SQUARE_BRACKET

public static final int LEFT_SQUARE_BRACKET
Token type for "[".

See Also:
Constant Field Values

RIGHT_SQUARE_BRACKET

public static final int RIGHT_SQUARE_BRACKET
Token type for "]".

See Also:
Constant Field Values

LEFT_PARENTHESIS

public static final int LEFT_PARENTHESIS
Token type for "(".

See Also:
Constant Field Values

RIGHT_PARENTHESIS

public static final int RIGHT_PARENTHESIS
Token type for ")".

See Also:
Constant Field Values

DOT

public static final int DOT
Token type for ".".

See Also:
Constant Field Values

DOT_DOT

public static final int DOT_DOT
Token type for "..".

See Also:
Constant Field Values

DOT_DOT_DOT

public static final int DOT_DOT_DOT
Token type for "...".

See Also:
Constant Field Values

NOT

public static final int NOT
Token type for "!".

See Also:
Constant Field Values

COMPARE_NOT_EQUAL

public static final int COMPARE_NOT_EQUAL
Token type for "!=".

See Also:
Constant Field Values

EQUAL

public static final int EQUAL
Token type for "=".

See Also:
Constant Field Values

FIND_REGEX

public static final int FIND_REGEX
Token type for "~=".

See Also:
Constant Field Values

MATCH_REGEX

public static final int MATCH_REGEX
Token type for "~==".

See Also:
Constant Field Values

PATTERN_REGEX

public static final int PATTERN_REGEX
Token type for "~"

See Also:
Constant Field Values

COMPARE_IDENTICAL

public static final int COMPARE_IDENTICAL
Token type for "==".

See Also:
Constant Field Values

COMPARE_EQUAL

public static final int COMPARE_EQUAL
Token type for ":=".

See Also:
Constant Field Values

COMPARE_LESS_THAN

public static final int COMPARE_LESS_THAN
Token type for "<".

See Also:
Constant Field Values

COMPARE_LESS_THAN_EQUAL

public static final int COMPARE_LESS_THAN_EQUAL
Token type for "<=".

See Also:
Constant Field Values

COMPARE_GREATER_THAN

public static final int COMPARE_GREATER_THAN
Token type for ">".

See Also:
Constant Field Values

COMPARE_GREATER_THAN_EQUAL

public static final int COMPARE_GREATER_THAN_EQUAL
Token type for ">=".

See Also:
Constant Field Values

COMPARE_TO

public static final int COMPARE_TO
Token type for "<=>".

See Also:
Constant Field Values

NAVIGATE

public static final int NAVIGATE
Token type for "->".

See Also:
Constant Field Values

LOGICAL_OR

public static final int LOGICAL_OR
Token type for "||".

See Also:
Constant Field Values

LOGICAL_AND

public static final int LOGICAL_AND
Token type for "&&".

See Also:
Constant Field Values

PLUS

public static final int PLUS
Token type for "+".

See Also:
Constant Field Values

PLUS_PLUS

public static final int PLUS_PLUS
Token type for "++".

See Also:
Constant Field Values

PLUS_EQUAL

public static final int PLUS_EQUAL
Token type for "+=".

See Also:
Constant Field Values

MINUS

public static final int MINUS
Token type for "-".

See Also:
Constant Field Values

MINUS_MINUS

public static final int MINUS_MINUS
Token type for "--".

See Also:
Constant Field Values

MINUS_EQUAL

public static final int MINUS_EQUAL
Token type for "-=".

See Also:
Constant Field Values

DIVIDE

public static final int DIVIDE
Token type for "/".

See Also:
Constant Field Values

DIVIDE_EQUAL

public static final int DIVIDE_EQUAL
Token type for "/=".

See Also:
Constant Field Values

MOD

public static final int MOD
Token type for "%".

See Also:
Constant Field Values

MOD_EQUAL

public static final int MOD_EQUAL
Token type for "%=".

See Also:
Constant Field Values

MULTIPLY

public static final int MULTIPLY
Token type for "*".

See Also:
Constant Field Values

MULTIPLY_EQUAL

public static final int MULTIPLY_EQUAL
Token type for "*=".

See Also:
Constant Field Values

COMMA

public static final int COMMA
See Also:
Constant Field Values

COLON

public static final int COLON
Token type for ":".

See Also:
Constant Field Values

SEMICOLON

public static final int SEMICOLON
Token type for ";".

See Also:
Constant Field Values

QUESTION

public static final int QUESTION
Token type for "?".

See Also:
Constant Field Values

PIPE

public static final int PIPE
Token type for "|".

See Also:
Constant Field Values

LEFT_SHIFT

public static final int LEFT_SHIFT
Token type for "<<".

See Also:
Constant Field Values

RIGHT_SHIFT

public static final int RIGHT_SHIFT
Token type for ">>".

See Also:
Constant Field Values

DOUBLE_QUOTE_STRING

public static final int DOUBLE_QUOTE_STRING
Token type for double-quoted string literal.

See Also:
Constant Field Values

SINGLE_QUOTE_STRING

public static final int SINGLE_QUOTE_STRING
Token type for single-quoted string literal.

See Also:
Constant Field Values

IDENTIFIER

public static final int IDENTIFIER
Token type for identifier.

See Also:
Constant Field Values

INTEGER_NUMBER

public static final int INTEGER_NUMBER
Token type for integral number.

See Also:
Constant Field Values

FLOAT_NUMBER

public static final int FLOAT_NUMBER
Token type for floating-point number.

See Also:
Constant Field Values

KEYWORD_ABSTRACT

public static final int KEYWORD_ABSTRACT
See Also:
Constant Field Values

KEYWORD_AS

public static final int KEYWORD_AS
See Also:
Constant Field Values

KEYWORD_BREAK

public static final int KEYWORD_BREAK
See Also:
Constant Field Values

KEYWORD_CASE

public static final int KEYWORD_CASE
See Also:
Constant Field Values

KEYWORD_CATCH

public static final int KEYWORD_CATCH
See Also:
Constant Field Values

KEYWORD_CLASS

public static final int KEYWORD_CLASS
See Also:
Constant Field Values

KEYWORD_CONST

public static final int KEYWORD_CONST
See Also:
Constant Field Values

KEYWORD_CONTINUE

public static final int KEYWORD_CONTINUE
See Also:
Constant Field Values

KEYWORD_DEFAULT

public static final int KEYWORD_DEFAULT
See Also:
Constant Field Values

KEYWORD_DO

public static final int KEYWORD_DO
See Also:
Constant Field Values

KEYWORD_ELSE

public static final int KEYWORD_ELSE
See Also:
Constant Field Values

KEYWORD_EXTENDS

public static final int KEYWORD_EXTENDS
See Also:
Constant Field Values

KEYWORD_FINAL

public static final int KEYWORD_FINAL
See Also:
Constant Field Values

KEYWORD_FINALLY

public static final int KEYWORD_FINALLY
See Also:
Constant Field Values

KEYWORD_FOR

public static final int KEYWORD_FOR
See Also:
Constant Field Values

KEYWORD_GOTO

public static final int KEYWORD_GOTO
See Also:
Constant Field Values

KEYWORD_IF

public static final int KEYWORD_IF
See Also:
Constant Field Values

KEYWORD_IMPLEMENTS

public static final int KEYWORD_IMPLEMENTS
See Also:
Constant Field Values

KEYWORD_IMPORT

public static final int KEYWORD_IMPORT
See Also:
Constant Field Values

KEYWORD_INSTANCEOF

public static final int KEYWORD_INSTANCEOF
See Also:
Constant Field Values

KEYWORD_INTERFACE

public static final int KEYWORD_INTERFACE
See Also:
Constant Field Values

KEYWORD_NATIVE

public static final int KEYWORD_NATIVE
See Also:
Constant Field Values

KEYWORD_NEW

public static final int KEYWORD_NEW
See Also:
Constant Field Values

KEYWORD_PACKAGE

public static final int KEYWORD_PACKAGE
See Also:
Constant Field Values

KEYWORD_PRIVATE

public static final int KEYWORD_PRIVATE
See Also:
Constant Field Values

KEYWORD_PROTECTED

public static final int KEYWORD_PROTECTED
See Also:
Constant Field Values

KEYWORD_PUBLIC

public static final int KEYWORD_PUBLIC
See Also:
Constant Field Values

KEYWORD_RETURN

public static final int KEYWORD_RETURN
See Also:
Constant Field Values

KEYWORD_STATIC

public static final int KEYWORD_STATIC
See Also:
Constant Field Values

KEYWORD_SUPER

public static final int KEYWORD_SUPER
See Also:
Constant Field Values

KEYWORD_SWITCH

public static final int KEYWORD_SWITCH
See Also:
Constant Field Values

KEYWORD_SYNCHRONIZED

public static final int KEYWORD_SYNCHRONIZED
See Also:
Constant Field Values

KEYWORD_THIS

public static final int KEYWORD_THIS
See Also:
Constant Field Values

KEYWORD_THROW

public static final int KEYWORD_THROW
See Also:
Constant Field Values

KEYWORD_THROWS

public static final int KEYWORD_THROWS
See Also:
Constant Field Values

KEYWORD_TRY

public static final int KEYWORD_TRY
See Also:
Constant Field Values

KEYWORD_WHILE

public static final int KEYWORD_WHILE
See Also:
Constant Field Values

KEYWORD_PROPERTY

public static final int KEYWORD_PROPERTY
See Also:
Constant Field Values

KEYWORD_TRUE

public static final int KEYWORD_TRUE
See Also:
Constant Field Values

KEYWORD_FALSE

public static final int KEYWORD_FALSE
See Also:
Constant Field Values

KEYWORD_ASSERT

public static final int KEYWORD_ASSERT
See Also:
Constant Field Values

KEYWORD_NULL

public static final int KEYWORD_NULL
See Also:
Constant Field Values

KEYWORD_VOID

public static final int KEYWORD_VOID
See Also:
Constant Field Values

KEYWORD_INT

public static final int KEYWORD_INT
See Also:
Constant Field Values

KEYWORD_FLOAT

public static final int KEYWORD_FLOAT
See Also:
Constant Field Values

KEYWORD_DOUBLE

public static final int KEYWORD_DOUBLE
See Also:
Constant Field Values

KEYWORD_CHAR

public static final int KEYWORD_CHAR
See Also:
Constant Field Values

KEYWORD_BYTE

public static final int KEYWORD_BYTE
See Also:
Constant Field Values

KEYWORD_LONG

public static final int KEYWORD_LONG
See Also:
Constant Field Values

KEYWORD_SHORT

public static final int KEYWORD_SHORT
See Also:
Constant Field Values

KEYWORD_BOOLEAN

public static final int KEYWORD_BOOLEAN
See Also:
Constant Field Values

KEYWORD_DEF

public static final int KEYWORD_DEF
See Also:
Constant Field Values

KEYWORD_TRANSIENT

public static final int KEYWORD_TRANSIENT
See Also:
Constant Field Values

KEYWORD_VOLATILE

public static final int KEYWORD_VOLATILE
See Also:
Constant Field Values

KEYWORD_IN

public static final int KEYWORD_IN
See Also:
Constant Field Values

SYNTH_METHOD

public static final int SYNTH_METHOD
See Also:
Constant Field Values

SYNTH_PARAMETER_DECLARATION

public static final int SYNTH_PARAMETER_DECLARATION
See Also:
Constant Field Values

SYNTH_LIST

public static final int SYNTH_LIST
See Also:
Constant Field Values

SYNTH_MAP

public static final int SYNTH_MAP
See Also:
Constant Field Values

SYNTH_POSTFIX

public static final int SYNTH_POSTFIX
See Also:
Constant Field Values

SYNTH_PREFIX

public static final int SYNTH_PREFIX
See Also:
Constant Field Values

SYNTH_CAST

public static final int SYNTH_CAST
See Also:
Constant Field Values

SYNTH_BLOCK

public static final int SYNTH_BLOCK
See Also:
Constant Field Values

SYNTH_CLOSURE

public static final int SYNTH_CLOSURE
See Also:
Constant Field Values

SYNTH_LABEL

public static final int SYNTH_LABEL
See Also:
Constant Field Values
Constructor Detail

Token

protected Token(int type,
                java.lang.String text,
                int startLine,
                int startColumn)
Construct.

Parameters:
type - Type of the token.
text - Actual text.
startLine - Starting line within source.
startColumn - Starting column within source.
Method Detail

getKeywordMap

public static java.util.Map getKeywordMap()

newToken

public static Token newToken(int type,
                             int startLine,
                             int startColumn)
Creates the token of the given id


getTokenDescription

public static java.lang.String getTokenDescription(int type)

getType

public int getType()
Retrieve the type.

Returns:
The type.

getInterpretation

public int getInterpretation()
Retrieve the interpretation (usually, but not always, the same as type.


setInterpretation

public void setInterpretation(int type)
Sets an interpretation for the token.


getText

public java.lang.String getText()
Retrieve the actual token text.

Returns:
The text.

getStartLine

public int getStartLine()
Retrieve the starting line within the source.

Returns:
The starting line.

getStartColumn

public int getStartColumn()
Retrieve the starting column within the source.

Returns:
The starting column.

getDescription

public java.lang.String getDescription()

toString

public java.lang.String toString()

newline

public static Token newline(int startLine,
                            int startColumn)
Factory method for token for "\n".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

leftCurlyBrace

public static Token leftCurlyBrace(int startLine,
                                   int startColumn)
Factory method for token for "{".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

rightCurlyBrace

public static Token rightCurlyBrace(int startLine,
                                    int startColumn)
Factory method for token for "}".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

leftSquareBracket

public static Token leftSquareBracket(int startLine,
                                      int startColumn)
Factory method for token for "[".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

rightSquareBracket

public static Token rightSquareBracket(int startLine,
                                       int startColumn)
Factory method for token for "]".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

leftParenthesis

public static Token leftParenthesis(int startLine,
                                    int startColumn)
Factory method for token for "(".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

rightParenthesis

public static Token rightParenthesis(int startLine,
                                     int startColumn)
Factory method for token for ")".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

dot

public static Token dot(int startLine,
                        int startColumn)
Factory method for token for ".".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

dotDot

public static Token dotDot(int startLine,
                           int startColumn)

dotDotDot

public static Token dotDotDot(int startLine,
                              int startColumn)

not

public static Token not(int startLine,
                        int startColumn)
Factory method for token for "!".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

compareNotEqual

public static Token compareNotEqual(int startLine,
                                    int startColumn)
Factory method for token for "!=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

findRegex

public static Token findRegex(int startLine,
                              int startColumn)
Factory method for token for "~=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

matchRegex

public static Token matchRegex(int startLine,
                               int startColumn)
Factory method for token for "~==".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

equal

public static Token equal(int startLine,
                          int startColumn)
Factory method for token for "=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

compareIdentical

public static Token compareIdentical(int startLine,
                                     int startColumn)
Factory method for token for "==".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

compareEqual

public static Token compareEqual(int startLine,
                                 int startColumn)
Factory method for token for ":=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

compareLessThan

public static Token compareLessThan(int startLine,
                                    int startColumn)
Factory method for token for "<".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

compareLessThanEqual

public static Token compareLessThanEqual(int startLine,
                                         int startColumn)
Factory method for token for "<=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

compareGreaterThan

public static Token compareGreaterThan(int startLine,
                                       int startColumn)
Factory method for token for ">".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

compareGreaterThanEqual

public static Token compareGreaterThanEqual(int startLine,
                                            int startColumn)
Factory method for token for ">=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

compareTo

public static Token compareTo(int startLine,
                              int startColumn)
Factory method for token for "<=>".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

navigate

public static Token navigate(int startLine,
                             int startColumn)
Factory method for token for "->".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

logicalOr

public static Token logicalOr(int startLine,
                              int startColumn)
Factory method for token for "||".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

logicalAnd

public static Token logicalAnd(int startLine,
                               int startColumn)
Factory method for token for "&&".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

plus

public static Token plus(int startLine,
                         int startColumn)
Factory method for token for "+".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

plusPlus

public static Token plusPlus(int startLine,
                             int startColumn)
Factory method for token for "++".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

plusEqual

public static Token plusEqual(int startLine,
                              int startColumn)
Factory method for token for "+=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

minus

public static Token minus(int startLine,
                          int startColumn)
Factory method for token for "-".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

minusMinus

public static Token minusMinus(int startLine,
                               int startColumn)
Factory method for token for "--".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

minusEqual

public static Token minusEqual(int startLine,
                               int startColumn)
Factory method for token for "-=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

divide

public static Token divide(int startLine,
                           int startColumn)
Factory method for token for "/".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

divideEqual

public static Token divideEqual(int startLine,
                                int startColumn)
Factory method for token for "/=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

mod

public static Token mod(int startLine,
                        int startColumn)
Factory method for token for "%".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

modEqual

public static Token modEqual(int startLine,
                             int startColumn)
Factory method for token for "%=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

multiply

public static Token multiply(int startLine,
                             int startColumn)
Factory method for token for "*".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

multiplyEqual

public static Token multiplyEqual(int startLine,
                                  int startColumn)
Factory method for token for "*=".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

comma

public static Token comma(int startLine,
                          int startColumn)

colon

public static Token colon(int startLine,
                          int startColumn)
Factory method for token for ":".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

semicolon

public static Token semicolon(int startLine,
                              int startColumn)
Factory method for token for ";".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

question

public static Token question(int startLine,
                             int startColumn)
Factory method for token for "?".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

pipe

public static Token pipe(int startLine,
                         int startColumn)
Factory method for token for "|".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

leftShift

public static Token leftShift(int startLine,
                              int startColumn)
Factory method for token for "<<".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

rightShift

public static Token rightShift(int startLine,
                               int startColumn)
Factory method for token for ">>".

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

doubleQuoteString

public static Token doubleQuoteString(int startLine,
                                      int startColumn,
                                      java.lang.String text)
Factory method for token for double-quoted string.

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

patternRegex

public static Token patternRegex(int startLine,
                                 int startColumn)
Factory method for token for double-quoted string.

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

singleQuoteString

public static Token singleQuoteString(int startLine,
                                      int startColumn,
                                      java.lang.String text)
Factory method for token for single-quoted string.

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

identifier

public static Token identifier(int startLine,
                               int startColumn,
                               java.lang.String text)
Factory method for token for identifier.

Parameters:
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

keyword

public static Token keyword(int startLine,
                            int startColumn,
                            java.lang.String text)

integerNumber

public static Token integerNumber(int startLine,
                                  int startColumn,
                                  java.lang.String text)

floatNumber

public static Token floatNumber(int startLine,
                                int startColumn,
                                java.lang.String text)

syntheticMethod

public static Token syntheticMethod()

syntheticParameterDeclaration

public static Token syntheticParameterDeclaration()

syntheticMap

public static Token syntheticMap()

syntheticList

public static Token syntheticList()

syntheticPostfix

public static Token syntheticPostfix()

syntheticPrefix

public static Token syntheticPrefix()

syntheticCast

public static Token syntheticCast()

syntheticBlock

public static Token syntheticBlock()

syntheticClosure

public static Token syntheticClosure()

toIdentifier

public Token toIdentifier()

newToken

protected static Token newToken(int type,
                                java.lang.String text,
                                int startLine,
                                int startColumn)
Generic factory method for a token.

Parameters:
type - The token type.
text - The token text.
startLine - Line upon which the token starts.
startColumn - Column upon which the token starts.
Returns:
The token.

isA

public boolean isA(int type)
Returns true if this token is of the specified type.


isA

public boolean isA(int[] types)
Returns true if this token is of any of the specified types.


isAssignmentToken

public boolean isAssignmentToken()
Returns true if this token performs an assignment to the LHS such as = or += or *= etc.


isPrimitiveTypeKeyword

public boolean isPrimitiveTypeKeyword(boolean evenVoid)
Returns true if the token is a primitive type.


isIdentifierOrPrimitiveTypeKeyword

public boolean isIdentifierOrPrimitiveTypeKeyword()
Returns true if the token is an identifier or a primitive type.


isValidNameReference

public boolean isValidNameReference()
Returns true if the token is a valid as a name that has already been declared. It is more general than a name that can be declared, as some names are reserved.


isModifier

public boolean isModifier()
Returns true if the token is a class modifier.


ofType

public static boolean ofType(int type,
                             int[] types)
Returns true if specified token type is in the supplied list.


isPrimitiveTypeKeyword

public static boolean isPrimitiveTypeKeyword(int type,
                                             boolean evenVoid)
Returns true if the token type is a primitive type.


isIdentifierOrPrimitiveTypeKeyword

public static boolean isIdentifierOrPrimitiveTypeKeyword(int type)
Returns true if the specified type is an identifier or a primitive type.


isValidNameReference

public static boolean isValidNameReference(int type)
Returns true if the specified type is valid as a reference to an existing name.


isAssignmentToken

public static boolean isAssignmentToken(int type)
Returns true if this token performs an assignment to the LHS such as = or += or *= etc.


isModifier

public static boolean isModifier(int type)
Returns true if the specified token type is a class modifier.



Copyright © 2003-2004 The Codehaus. All Rights Reserved.