org.anarres.cpp
Class Token

java.lang.Object
  extended by org.anarres.cpp.Token

public final class Token
extends Object

A Preprocessor token.

See Also:
Preprocessor

Field Summary
static int _TOKENS
          The number of possible semantic token types.
static int AND_EQ
          The token type AND_EQ.
static int ARROW
          The token type ARROW.
static int CCOMMENT
          The token type CCOMMENT.
static int CHARACTER
          The token type CHARACTER.
static int CPPCOMMENT
          The token type CPPCOMMENT.
static int DEC
          The token type DEC.
static int DIV_EQ
          The token type DIV_EQ.
static int ELLIPSIS
          The token type ELLIPSIS.
static int EOF
          The token type EOF.
static int EQ
          The token type EQ.
static int GE
          The token type GE.
static int HASH
          The token type HASH.
static int HEADER
          The token type HEADER.
static int IDENTIFIER
          The token type IDENTIFIER.
static int INC
          The token type INC.
static int INTEGER
          The token type INTEGER.
static int INVALID
          The token type INVALID.
static int LAND
          The token type LAND.
static int LAND_EQ
          The token type LAND_EQ.
static int LE
          The token type LE.
static int LITERAL
          The token type LITERAL.
static int LOR
          The token type LOR.
static int LOR_EQ
          The token type LOR_EQ.
static int LSH
          The token type LSH.
static int LSH_EQ
          The token type LSH_EQ.
static int M_ARG
          The token type M_ARG.
static int M_PASTE
          The token type M_PASTE.
static int M_STRING
          The token type M_STRING.
static int MOD_EQ
          The token type MOD_EQ.
static int MULT_EQ
          The token type MULT_EQ.
static int NE
          The token type NE.
static int NL
          The token type NL.
static int OR_EQ
          The token type OR_EQ.
static int P_LINE
          The token type P_LINE.
static int PASTE
          The token type PASTE.
static int PLUS_EQ
          The token type PLUS_EQ.
static int RANGE
          The token type RANGE.
static int RSH
          The token type RSH.
static int RSH_EQ
          The token type RSH_EQ.
static int STRING
          The token type STRING.
static int SUB_EQ
          The token type SUB_EQ.
static int WHITESPACE
          The token type WHITESPACE.
static int XOR_EQ
          The token type XOR_EQ.
 
Constructor Summary
Token(int type, int line, int column, String text)
           
Token(int type, int line, int column, String text, Object value)
           
 
Method Summary
 int getColumn()
          Returns the column at which this token started.
 int getLine()
          Returns the line at which this token started.
 String getText()
          Returns the original or generated text of this token.
static String getTokenName(int type)
          Returns the descriptive name of the given token type.
 int getType()
          Returns the semantic type of this token.
 Object getValue()
          Returns the semantic value of this token.
 String toString()
          Returns a description of this token, for debugging purposes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AND_EQ

public static final int AND_EQ
The token type AND_EQ.

See Also:
Constant Field Values

ARROW

public static final int ARROW
The token type ARROW.

See Also:
Constant Field Values

CHARACTER

public static final int CHARACTER
The token type CHARACTER.

See Also:
Constant Field Values

CCOMMENT

public static final int CCOMMENT
The token type CCOMMENT.

See Also:
Constant Field Values

CPPCOMMENT

public static final int CPPCOMMENT
The token type CPPCOMMENT.

See Also:
Constant Field Values

DEC

public static final int DEC
The token type DEC.

See Also:
Constant Field Values

DIV_EQ

public static final int DIV_EQ
The token type DIV_EQ.

See Also:
Constant Field Values

ELLIPSIS

public static final int ELLIPSIS
The token type ELLIPSIS.

See Also:
Constant Field Values

EOF

public static final int EOF
The token type EOF.

See Also:
Constant Field Values

EQ

public static final int EQ
The token type EQ.

See Also:
Constant Field Values

GE

public static final int GE
The token type GE.

See Also:
Constant Field Values

HASH

public static final int HASH
The token type HASH.

See Also:
Constant Field Values

HEADER

public static final int HEADER
The token type HEADER.

See Also:
Constant Field Values

IDENTIFIER

public static final int IDENTIFIER
The token type IDENTIFIER.

See Also:
Constant Field Values

INC

public static final int INC
The token type INC.

See Also:
Constant Field Values

INTEGER

public static final int INTEGER
The token type INTEGER.

See Also:
Constant Field Values

LAND

public static final int LAND
The token type LAND.

See Also:
Constant Field Values

LAND_EQ

public static final int LAND_EQ
The token type LAND_EQ.

See Also:
Constant Field Values

LE

public static final int LE
The token type LE.

See Also:
Constant Field Values

LITERAL

public static final int LITERAL
The token type LITERAL.

See Also:
Constant Field Values

LOR

public static final int LOR
The token type LOR.

See Also:
Constant Field Values

LOR_EQ

public static final int LOR_EQ
The token type LOR_EQ.

See Also:
Constant Field Values

LSH

public static final int LSH
The token type LSH.

See Also:
Constant Field Values

LSH_EQ

public static final int LSH_EQ
The token type LSH_EQ.

See Also:
Constant Field Values

MOD_EQ

public static final int MOD_EQ
The token type MOD_EQ.

See Also:
Constant Field Values

MULT_EQ

public static final int MULT_EQ
The token type MULT_EQ.

See Also:
Constant Field Values

NE

public static final int NE
The token type NE.

See Also:
Constant Field Values

NL

public static final int NL
The token type NL.

See Also:
Constant Field Values

OR_EQ

public static final int OR_EQ
The token type OR_EQ.

See Also:
Constant Field Values

PASTE

public static final int PASTE
The token type PASTE.

See Also:
Constant Field Values

PLUS_EQ

public static final int PLUS_EQ
The token type PLUS_EQ.

See Also:
Constant Field Values

RANGE

public static final int RANGE
The token type RANGE.

See Also:
Constant Field Values

RSH

public static final int RSH
The token type RSH.

See Also:
Constant Field Values

RSH_EQ

public static final int RSH_EQ
The token type RSH_EQ.

See Also:
Constant Field Values

STRING

public static final int STRING
The token type STRING.

See Also:
Constant Field Values

SUB_EQ

public static final int SUB_EQ
The token type SUB_EQ.

See Also:
Constant Field Values

WHITESPACE

public static final int WHITESPACE
The token type WHITESPACE.

See Also:
Constant Field Values

XOR_EQ

public static final int XOR_EQ
The token type XOR_EQ.

See Also:
Constant Field Values

M_ARG

public static final int M_ARG
The token type M_ARG.

See Also:
Constant Field Values

M_PASTE

public static final int M_PASTE
The token type M_PASTE.

See Also:
Constant Field Values

M_STRING

public static final int M_STRING
The token type M_STRING.

See Also:
Constant Field Values

P_LINE

public static final int P_LINE
The token type P_LINE.

See Also:
Constant Field Values

INVALID

public static final int INVALID
The token type INVALID.

See Also:
Constant Field Values

_TOKENS

public static final int _TOKENS
The number of possible semantic token types. Please note that not all token types below 255 are used.

See Also:
Constant Field Values
Constructor Detail

Token

public Token(int type,
             int line,
             int column,
             String text,
             Object value)

Token

public Token(int type,
             int line,
             int column,
             String text)
Method Detail

getType

public int getType()
Returns the semantic type of this token.


getLine

public int getLine()
Returns the line at which this token started. Lines are numbered from zero.


getColumn

public int getColumn()
Returns the column at which this token started. Columns are numbered from zero.


getText

public String getText()
Returns the original or generated text of this token. This is distinct from the semantic value of the token.

See Also:
getValue()

getValue

public Object getValue()
Returns the semantic value of this token. For strings, this is the parsed String. For integers, this is an Integer object. For other token types, as appropriate.

See Also:
getText()

toString

public String toString()
Returns a description of this token, for debugging purposes.

Overrides:
toString in class Object

getTokenName

public static final String getTokenName(int type)
Returns the descriptive name of the given token type. This is mostly used for stringification and debugging.



Copyright © 2007 Shevek, Anarres. All Rights Reserved.