org.mozilla.javascript
Class Token

java.lang.Object
  extended by org.mozilla.javascript.Token

public class Token
extends java.lang.Object

This class implements the JavaScript scanner. It is based on the C source files jsscan.c and jsscan.h in the jsref package.

Author:
Mike McCabe, Brendan Eich
See Also:
Parser

Nested Class Summary
static class Token.CommentType
           
 
Field Summary
static int ADD
          Token types.
static int AND
           
static int ARRAYCOMP
           
static int ARRAYLIT
          Token types.
static int ASSIGN
           
static int ASSIGN_ADD
           
static int ASSIGN_BITAND
           
static int ASSIGN_BITOR
           
static int ASSIGN_BITXOR
           
static int ASSIGN_DIV
           
static int ASSIGN_LSH
           
static int ASSIGN_MOD
           
static int ASSIGN_MUL
           
static int ASSIGN_RSH
           
static int ASSIGN_SUB
           
static int ASSIGN_URSH
           
static int BINDNAME
          Token types.
static int BITAND
          Token types.
static int BITNOT
          Token types.
static int BITOR
          Token types.
static int BITXOR
          Token types.
static int BLOCK
           
static int BREAK
           
static int CALL
          Token types.
static int CASE
           
static int CATCH
           
static int CATCH_SCOPE
          Token types.
static int COLON
           
static int COLONCOLON
           
static int COMMA
           
static int COMMENT
           
static int CONST
           
static int CONTINUE
           
static int DEBUGGER
           
static int DEC
           
static int DEFAULT
           
static int DEFAULTNAMESPACE
          Token types.
static int DEL_REF
          Token types.
static int DELPROP
          Token types.
static int DIV
          Token types.
static int DO
           
static int DOT
           
static int DOTDOT
           
static int DOTQUERY
           
static int ELSE
           
static int EMPTY
           
static int ENTERWITH
          Token types.
static int ENUM_ID
          Token types.
static int ENUM_INIT_ARRAY
          Token types.
static int ENUM_INIT_KEYS
          Token types.
static int ENUM_INIT_VALUES
          Token types.
static int ENUM_NEXT
          Token types.
static int EOF
          Token types.
static int EOL
          Token types.
static int EQ
          Token types.
static int ERROR
          Token types.
static int ESCXMLATTR
          Token types.
static int ESCXMLTEXT
          Token types.
static int EXPORT
           
static int EXPR_RESULT
           
static int EXPR_VOID
           
static int FALSE
          Token types.
static int FINALLY
           
static int FIRST_ASSIGN
           
static int FIRST_BYTECODE_TOKEN
          Token types.
static int FOR
           
static int FUNCTION
           
static int GE
          Token types.
static int GENEXPR
           
static int GET
           
static int GET_REF
          Token types.
static int GETELEM
          Token types.
static int GETPROP
          Token types.
static int GETPROPNOWARN
          Token types.
static int GETVAR
          Token types.
static int GOTO
          Token types.
static int GT
          Token types.
static int HOOK
           
static int IF
           
static int IFEQ
          Token types.
static int IFNE
          Token types.
static int IMPORT
           
static int IN
          Token types.
static int INC
           
static int INSTANCEOF
          Token types.
static int JSR
           
static int LABEL
           
static int LAST_ASSIGN
           
static int LAST_BYTECODE_TOKEN
           
static int LAST_TOKEN
           
static int LB
           
static int LC
           
static int LE
          Token types.
static int LEAVEWITH
          Token types.
static int LET
           
static int LETEXPR
           
static int LOCAL_BLOCK
           
static int LOCAL_LOAD
          Token types.
static int LOOP
           
static int LP
           
static int LSH
          Token types.
static int LT
          Token types.
static int MOD
          Token types.
static int MUL
          Token types.
static int NAME
          Token types.
static int NE
          Token types.
static int NEG
          Token types.
static int NEW
          Token types.
static int NOT
          Token types.
static int NULL
          Token types.
static int NUMBER
          Token types.
static int OBJECTLIT
          Token types.
static int OR
           
static int POS
          Token types.
static boolean printTrees
           
static int RB
           
static int RC
           
static int REF_CALL
          Token types.
static int REF_MEMBER
          Token types.
static int REF_NAME
          Token types.
static int REF_NS_MEMBER
          Token types.
static int REF_NS_NAME
          Token types.
static int REF_SPECIAL
          Token types.
static int REGEXP
          Token types.
static int RESERVED
           
static int RETHROW
          Token types.
static int RETURN
          Token types.
static int RETURN_RESULT
          Token types.
static int RP
           
static int RSH
          Token types.
static int SCRIPT
           
static int SEMI
           
static int SET
           
static int SET_REF
          Token types.
static int SET_REF_OP
           
static int SETCONST
           
static int SETCONSTVAR
           
static int SETELEM
          Token types.
static int SETELEM_OP
           
static int SETNAME
          Token types.
static int SETPROP
          Token types.
static int SETPROP_OP
           
static int SETVAR
          Token types.
static int SHEQ
          Token types.
static int SHNE
          Token types.
static int STRICT_SETNAME
          Token types.
static int STRING
          Token types.
static int SUB
          Token types.
static int SWITCH
           
static int TARGET
           
static int THIS
          Token types.
static int THISFN
          Token types.
static int THROW
          Token types.
static int TO_DOUBLE
           
static int TO_OBJECT
           
static int TRUE
          Token types.
static int TRY
           
static int TYPEOF
          Token types.
static int TYPEOFNAME
           
static int URSH
          Token types.
static int USE_STACK
           
static int VAR
           
static int VOID
           
static int WHILE
           
static int WITH
           
static int WITHEXPR
           
static int XML
           
static int XMLATTR
           
static int XMLEND
           
static int YIELD
          Token types.
 
Constructor Summary
Token()
           
 
Method Summary
static boolean isValidToken(int code)
          Return true if the passed code is a valid Token constant.
static java.lang.String keywordToName(int token)
          Convert a keyword token to a name string for use with the Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER feature.
static java.lang.String name(int token)
          Returns a name for the token.
static java.lang.String typeToName(int token)
          Always returns a human-readable string for the token name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

printTrees

public static final boolean printTrees
See Also:
Constant Field Values

ERROR

public static final int ERROR
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

EOF

public static final int EOF
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

EOL

public static final int EOL
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

FIRST_BYTECODE_TOKEN

public static final int FIRST_BYTECODE_TOKEN
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

ENTERWITH

public static final int ENTERWITH
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

LEAVEWITH

public static final int LEAVEWITH
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

RETURN

public static final int RETURN
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

GOTO

public static final int GOTO
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

IFEQ

public static final int IFEQ
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

IFNE

public static final int IFNE
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

SETNAME

public static final int SETNAME
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

BITOR

public static final int BITOR
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

BITXOR

public static final int BITXOR
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

BITAND

public static final int BITAND
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

EQ

public static final int EQ
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

NE

public static final int NE
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

LT

public static final int LT
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

LE

public static final int LE
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

GT

public static final int GT
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

GE

public static final int GE
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

LSH

public static final int LSH
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

RSH

public static final int RSH
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

URSH

public static final int URSH
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

ADD

public static final int ADD
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

SUB

public static final int SUB
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

MUL

public static final int MUL
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

DIV

public static final int DIV
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

MOD

public static final int MOD
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

NOT

public static final int NOT
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

BITNOT

public static final int BITNOT
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

POS

public static final int POS
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

NEG

public static final int NEG
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

NEW

public static final int NEW
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

DELPROP

public static final int DELPROP
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

TYPEOF

public static final int TYPEOF
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

GETPROP

public static final int GETPROP
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

GETPROPNOWARN

public static final int GETPROPNOWARN
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

SETPROP

public static final int SETPROP
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

GETELEM

public static final int GETELEM
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

SETELEM

public static final int SETELEM
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

CALL

public static final int CALL
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

NAME

public static final int NAME
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

NUMBER

public static final int NUMBER
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

STRING

public static final int STRING
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

NULL

public static final int NULL
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

THIS

public static final int THIS
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

FALSE

public static final int FALSE
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

TRUE

public static final int TRUE
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

SHEQ

public static final int SHEQ
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

SHNE

public static final int SHNE
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

REGEXP

public static final int REGEXP
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

BINDNAME

public static final int BINDNAME
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

THROW

public static final int THROW
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

RETHROW

public static final int RETHROW
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

IN

public static final int IN
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

INSTANCEOF

public static final int INSTANCEOF
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

LOCAL_LOAD

public static final int LOCAL_LOAD
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

GETVAR

public static final int GETVAR
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

SETVAR

public static final int SETVAR
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

CATCH_SCOPE

public static final int CATCH_SCOPE
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

ENUM_INIT_KEYS

public static final int ENUM_INIT_KEYS
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

ENUM_INIT_VALUES

public static final int ENUM_INIT_VALUES
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

ENUM_INIT_ARRAY

public static final int ENUM_INIT_ARRAY
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

ENUM_NEXT

public static final int ENUM_NEXT
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

ENUM_ID

public static final int ENUM_ID
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

THISFN

public static final int THISFN
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

RETURN_RESULT

public static final int RETURN_RESULT
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

ARRAYLIT

public static final int ARRAYLIT
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

OBJECTLIT

public static final int OBJECTLIT
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

GET_REF

public static final int GET_REF
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

SET_REF

public static final int SET_REF
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

DEL_REF

public static final int DEL_REF
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

REF_CALL

public static final int REF_CALL
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

REF_SPECIAL

public static final int REF_SPECIAL
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

YIELD

public static final int YIELD
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

STRICT_SETNAME

public static final int STRICT_SETNAME
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

DEFAULTNAMESPACE

public static final int DEFAULTNAMESPACE
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

ESCXMLATTR

public static final int ESCXMLATTR
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

ESCXMLTEXT

public static final int ESCXMLTEXT
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

REF_MEMBER

public static final int REF_MEMBER
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

REF_NS_MEMBER

public static final int REF_NS_MEMBER
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

REF_NAME

public static final int REF_NAME
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

REF_NS_NAME

public static final int REF_NS_NAME
Token types. These values correspond to JSTokenType values in jsscan.c.

See Also:
Constant Field Values

LAST_BYTECODE_TOKEN

public static final int LAST_BYTECODE_TOKEN
See Also:
Constant Field Values

TRY

public static final int TRY
See Also:
Constant Field Values

SEMI

public static final int SEMI
See Also:
Constant Field Values

LB

public static final int LB
See Also:
Constant Field Values

RB

public static final int RB
See Also:
Constant Field Values

LC

public static final int LC
See Also:
Constant Field Values

RC

public static final int RC
See Also:
Constant Field Values

LP

public static final int LP
See Also:
Constant Field Values

RP

public static final int RP
See Also:
Constant Field Values

COMMA

public static final int COMMA
See Also:
Constant Field Values

ASSIGN

public static final int ASSIGN
See Also:
Constant Field Values

ASSIGN_BITOR

public static final int ASSIGN_BITOR
See Also:
Constant Field Values

ASSIGN_BITXOR

public static final int ASSIGN_BITXOR
See Also:
Constant Field Values

ASSIGN_BITAND

public static final int ASSIGN_BITAND
See Also:
Constant Field Values

ASSIGN_LSH

public static final int ASSIGN_LSH
See Also:
Constant Field Values

ASSIGN_RSH

public static final int ASSIGN_RSH
See Also:
Constant Field Values

ASSIGN_URSH

public static final int ASSIGN_URSH
See Also:
Constant Field Values

ASSIGN_ADD

public static final int ASSIGN_ADD
See Also:
Constant Field Values

ASSIGN_SUB

public static final int ASSIGN_SUB
See Also:
Constant Field Values

ASSIGN_MUL

public static final int ASSIGN_MUL
See Also:
Constant Field Values

ASSIGN_DIV

public static final int ASSIGN_DIV
See Also:
Constant Field Values

ASSIGN_MOD

public static final int ASSIGN_MOD
See Also:
Constant Field Values

FIRST_ASSIGN

public static final int FIRST_ASSIGN
See Also:
Constant Field Values

LAST_ASSIGN

public static final int LAST_ASSIGN
See Also:
Constant Field Values

HOOK

public static final int HOOK
See Also:
Constant Field Values

COLON

public static final int COLON
See Also:
Constant Field Values

OR

public static final int OR
See Also:
Constant Field Values

AND

public static final int AND
See Also:
Constant Field Values

INC

public static final int INC
See Also:
Constant Field Values

DEC

public static final int DEC
See Also:
Constant Field Values

DOT

public static final int DOT
See Also:
Constant Field Values

FUNCTION

public static final int FUNCTION
See Also:
Constant Field Values

EXPORT

public static final int EXPORT
See Also:
Constant Field Values

IMPORT

public static final int IMPORT
See Also:
Constant Field Values

IF

public static final int IF
See Also:
Constant Field Values

ELSE

public static final int ELSE
See Also:
Constant Field Values

SWITCH

public static final int SWITCH
See Also:
Constant Field Values

CASE

public static final int CASE
See Also:
Constant Field Values

DEFAULT

public static final int DEFAULT
See Also:
Constant Field Values

WHILE

public static final int WHILE
See Also:
Constant Field Values

DO

public static final int DO
See Also:
Constant Field Values

FOR

public static final int FOR
See Also:
Constant Field Values

BREAK

public static final int BREAK
See Also:
Constant Field Values

CONTINUE

public static final int CONTINUE
See Also:
Constant Field Values

VAR

public static final int VAR
See Also:
Constant Field Values

WITH

public static final int WITH
See Also:
Constant Field Values

CATCH

public static final int CATCH
See Also:
Constant Field Values

FINALLY

public static final int FINALLY
See Also:
Constant Field Values

VOID

public static final int VOID
See Also:
Constant Field Values

RESERVED

public static final int RESERVED
See Also:
Constant Field Values

EMPTY

public static final int EMPTY
See Also:
Constant Field Values

BLOCK

public static final int BLOCK
See Also:
Constant Field Values

LABEL

public static final int LABEL
See Also:
Constant Field Values

TARGET

public static final int TARGET
See Also:
Constant Field Values

LOOP

public static final int LOOP
See Also:
Constant Field Values

EXPR_VOID

public static final int EXPR_VOID
See Also:
Constant Field Values

EXPR_RESULT

public static final int EXPR_RESULT
See Also:
Constant Field Values

JSR

public static final int JSR
See Also:
Constant Field Values

SCRIPT

public static final int SCRIPT
See Also:
Constant Field Values

TYPEOFNAME

public static final int TYPEOFNAME
See Also:
Constant Field Values

USE_STACK

public static final int USE_STACK
See Also:
Constant Field Values

SETPROP_OP

public static final int SETPROP_OP
See Also:
Constant Field Values

SETELEM_OP

public static final int SETELEM_OP
See Also:
Constant Field Values

LOCAL_BLOCK

public static final int LOCAL_BLOCK
See Also:
Constant Field Values

SET_REF_OP

public static final int SET_REF_OP
See Also:
Constant Field Values

DOTDOT

public static final int DOTDOT
See Also:
Constant Field Values

COLONCOLON

public static final int COLONCOLON
See Also:
Constant Field Values

XML

public static final int XML
See Also:
Constant Field Values

DOTQUERY

public static final int DOTQUERY
See Also:
Constant Field Values

XMLATTR

public static final int XMLATTR
See Also:
Constant Field Values

XMLEND

public static final int XMLEND
See Also:
Constant Field Values

TO_OBJECT

public static final int TO_OBJECT
See Also:
Constant Field Values

TO_DOUBLE

public static final int TO_DOUBLE
See Also:
Constant Field Values

GET

public static final int GET
See Also:
Constant Field Values

SET

public static final int SET
See Also:
Constant Field Values

LET

public static final int LET
See Also:
Constant Field Values

CONST

public static final int CONST
See Also:
Constant Field Values

SETCONST

public static final int SETCONST
See Also:
Constant Field Values

SETCONSTVAR

public static final int SETCONSTVAR
See Also:
Constant Field Values

ARRAYCOMP

public static final int ARRAYCOMP
See Also:
Constant Field Values

LETEXPR

public static final int LETEXPR
See Also:
Constant Field Values

WITHEXPR

public static final int WITHEXPR
See Also:
Constant Field Values

DEBUGGER

public static final int DEBUGGER
See Also:
Constant Field Values

COMMENT

public static final int COMMENT
See Also:
Constant Field Values

GENEXPR

public static final int GENEXPR
See Also:
Constant Field Values

LAST_TOKEN

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

Token

public Token()
Method Detail

name

public static java.lang.String name(int token)
Returns a name for the token. If Rhino is compiled with certain hardcoded debugging flags in this file, it calls #typeToName; otherwise it returns a string whose value is the token number.


typeToName

public static java.lang.String typeToName(int token)
Always returns a human-readable string for the token name. For instance, FINALLY has the name "FINALLY".

Parameters:
token - the token code
Returns:
the actual name for the token code

keywordToName

public static java.lang.String keywordToName(int token)
Convert a keyword token to a name string for use with the Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER feature.

Parameters:
token - A token
Returns:
the corresponding name string

isValidToken

public static boolean isValidToken(int code)
Return true if the passed code is a valid Token constant.

Parameters:
code - a potential token code
Returns:
true if it's a known token