Class Token

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

public class Token extends 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:
  • Field Details

    • printTrees

      public static final boolean printTrees
      See Also:
    • ERROR

      public static final int ERROR
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • FIRST_TOKEN

      public static final int FIRST_TOKEN
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • EOF

      public static final int EOF
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • EOL

      public static final int EOL
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • FIRST_BYTECODE_TOKEN

      public static final int FIRST_BYTECODE_TOKEN
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ENTERWITH

      public static final int ENTERWITH
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • LEAVEWITH

      public static final int LEAVEWITH
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • RETURN

      public static final int RETURN
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • GOTO

      public static final int GOTO
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • IFEQ

      public static final int IFEQ
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • IFNE

      public static final int IFNE
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • SETNAME

      public static final int SETNAME
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • BITOR

      public static final int BITOR
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • BITXOR

      public static final int BITXOR
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • BITAND

      public static final int BITAND
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • EQ

      public static final int EQ
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • NE

      public static final int NE
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • LT

      public static final int LT
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • LE

      public static final int LE
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • GT

      public static final int GT
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • GE

      public static final int GE
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • LSH

      public static final int LSH
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • RSH

      public static final int RSH
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • URSH

      public static final int URSH
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ADD

      public static final int ADD
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • SUB

      public static final int SUB
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • MUL

      public static final int MUL
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • DIV

      public static final int DIV
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • MOD

      public static final int MOD
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • NOT

      public static final int NOT
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • BITNOT

      public static final int BITNOT
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • POS

      public static final int POS
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • NEG

      public static final int NEG
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • NEW

      public static final int NEW
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • DELPROP

      public static final int DELPROP
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • TYPEOF

      public static final int TYPEOF
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • GETPROP

      public static final int GETPROP
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • GETPROPNOWARN

      public static final int GETPROPNOWARN
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • SETPROP

      public static final int SETPROP
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • GETELEM

      public static final int GETELEM
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • SETELEM

      public static final int SETELEM
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • CALL

      public static final int CALL
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • NAME

      public static final int NAME
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • NUMBER

      public static final int NUMBER
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • STRING

      public static final int STRING
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • NULL

      public static final int NULL
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • THIS

      public static final int THIS
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • FALSE

      public static final int FALSE
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • TRUE

      public static final int TRUE
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • SHEQ

      public static final int SHEQ
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • SHNE

      public static final int SHNE
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • REGEXP

      public static final int REGEXP
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • BINDNAME

      public static final int BINDNAME
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • THROW

      public static final int THROW
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • RETHROW

      public static final int RETHROW
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • IN

      public static final int IN
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • INSTANCEOF

      public static final int INSTANCEOF
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • LOCAL_LOAD

      public static final int LOCAL_LOAD
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • GETVAR

      public static final int GETVAR
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • SETVAR

      public static final int SETVAR
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • CATCH_SCOPE

      public static final int CATCH_SCOPE
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ENUM_INIT_KEYS

      public static final int ENUM_INIT_KEYS
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ENUM_INIT_VALUES

      public static final int ENUM_INIT_VALUES
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ENUM_INIT_ARRAY

      public static final int ENUM_INIT_ARRAY
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ENUM_INIT_VALUES_IN_ORDER

      public static final int ENUM_INIT_VALUES_IN_ORDER
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ENUM_NEXT

      public static final int ENUM_NEXT
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ENUM_ID

      public static final int ENUM_ID
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • THISFN

      public static final int THISFN
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • RETURN_RESULT

      public static final int RETURN_RESULT
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ARRAYLIT

      public static final int ARRAYLIT
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • OBJECTLIT

      public static final int OBJECTLIT
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • GET_REF

      public static final int GET_REF
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • SET_REF

      public static final int SET_REF
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • DEL_REF

      public static final int DEL_REF
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • REF_CALL

      public static final int REF_CALL
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • REF_SPECIAL

      public static final int REF_SPECIAL
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • YIELD

      public static final int YIELD
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • STRICT_SETNAME

      public static final int STRICT_SETNAME
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • EXP

      public static final int EXP
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • DEFAULTNAMESPACE

      public static final int DEFAULTNAMESPACE
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ESCXMLATTR

      public static final int ESCXMLATTR
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • ESCXMLTEXT

      public static final int ESCXMLTEXT
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • REF_MEMBER

      public static final int REF_MEMBER
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • REF_NS_MEMBER

      public static final int REF_NS_MEMBER
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • REF_NAME

      public static final int REF_NAME
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • REF_NS_NAME

      public static final int REF_NS_NAME
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • BIGINT

      public static final int BIGINT
      Token types. These values correspond to JSTokenType values in jsscan.c.
      See Also:
    • LAST_BYTECODE_TOKEN

      public static final int LAST_BYTECODE_TOKEN
      See Also:
    • TRY

      public static final int TRY
      See Also:
    • SEMI

      public static final int SEMI
      See Also:
    • LB

      public static final int LB
      See Also:
    • RB

      public static final int RB
      See Also:
    • LC

      public static final int LC
      See Also:
    • RC

      public static final int RC
      See Also:
    • LP

      public static final int LP
      See Also:
    • RP

      public static final int RP
      See Also:
    • COMMA

      public static final int COMMA
      See Also:
    • ASSIGN

      public static final int ASSIGN
      See Also:
    • ASSIGN_BITOR

      public static final int ASSIGN_BITOR
      See Also:
    • ASSIGN_LOGICAL_OR

      public static final int ASSIGN_LOGICAL_OR
      See Also:
    • ASSIGN_BITXOR

      public static final int ASSIGN_BITXOR
      See Also:
    • ASSIGN_BITAND

      public static final int ASSIGN_BITAND
      See Also:
    • ASSIGN_LOGICAL_AND

      public static final int ASSIGN_LOGICAL_AND
      See Also:
    • ASSIGN_LSH

      public static final int ASSIGN_LSH
      See Also:
    • ASSIGN_RSH

      public static final int ASSIGN_RSH
      See Also:
    • ASSIGN_URSH

      public static final int ASSIGN_URSH
      See Also:
    • ASSIGN_ADD

      public static final int ASSIGN_ADD
      See Also:
    • ASSIGN_SUB

      public static final int ASSIGN_SUB
      See Also:
    • ASSIGN_MUL

      public static final int ASSIGN_MUL
      See Also:
    • ASSIGN_DIV

      public static final int ASSIGN_DIV
      See Also:
    • ASSIGN_MOD

      public static final int ASSIGN_MOD
      See Also:
    • ASSIGN_EXP

      public static final int ASSIGN_EXP
      See Also:
    • ASSIGN_NULLISH

      public static final int ASSIGN_NULLISH
      See Also:
    • FIRST_ASSIGN

      public static final int FIRST_ASSIGN
      See Also:
    • LAST_ASSIGN

      public static final int LAST_ASSIGN
      See Also:
    • HOOK

      public static final int HOOK
      See Also:
    • COLON

      public static final int COLON
      See Also:
    • OR

      public static final int OR
      See Also:
    • AND

      public static final int AND
      See Also:
    • INC

      public static final int INC
      See Also:
    • DEC

      public static final int DEC
      See Also:
    • DOT

      public static final int DOT
      See Also:
    • FUNCTION

      public static final int FUNCTION
      See Also:
    • EXPORT

      public static final int EXPORT
      See Also:
    • IMPORT

      public static final int IMPORT
      See Also:
    • IF

      public static final int IF
      See Also:
    • ELSE

      public static final int ELSE
      See Also:
    • SWITCH

      public static final int SWITCH
      See Also:
    • CASE

      public static final int CASE
      See Also:
    • DEFAULT

      public static final int DEFAULT
      See Also:
    • WHILE

      public static final int WHILE
      See Also:
    • DO

      public static final int DO
      See Also:
    • FOR

      public static final int FOR
      See Also:
    • BREAK

      public static final int BREAK
      See Also:
    • CONTINUE

      public static final int CONTINUE
      See Also:
    • VAR

      public static final int VAR
      See Also:
    • WITH

      public static final int WITH
      See Also:
    • CATCH

      public static final int CATCH
      See Also:
    • FINALLY

      public static final int FINALLY
      See Also:
    • VOID

      public static final int VOID
      See Also:
    • RESERVED

      public static final int RESERVED
      See Also:
    • EMPTY

      public static final int EMPTY
      See Also:
    • COMPUTED_PROPERTY

      public static final int COMPUTED_PROPERTY
      See Also:
    • BLOCK

      public static final int BLOCK
      See Also:
    • LABEL

      public static final int LABEL
      See Also:
    • TARGET

      public static final int TARGET
      See Also:
    • LOOP

      public static final int LOOP
      See Also:
    • EXPR_VOID

      public static final int EXPR_VOID
      See Also:
    • EXPR_RESULT

      public static final int EXPR_RESULT
      See Also:
    • JSR

      public static final int JSR
      See Also:
    • SCRIPT

      public static final int SCRIPT
      See Also:
    • TYPEOFNAME

      public static final int TYPEOFNAME
      See Also:
    • USE_STACK

      public static final int USE_STACK
      See Also:
    • SETPROP_OP

      public static final int SETPROP_OP
      See Also:
    • SETELEM_OP

      public static final int SETELEM_OP
      See Also:
    • LOCAL_BLOCK

      public static final int LOCAL_BLOCK
      See Also:
    • SET_REF_OP

      public static final int SET_REF_OP
      See Also:
    • DOTDOT

      public static final int DOTDOT
      See Also:
    • COLONCOLON

      public static final int COLONCOLON
      See Also:
    • XML

      public static final int XML
      See Also:
    • DOTQUERY

      public static final int DOTQUERY
      See Also:
    • XMLATTR

      public static final int XMLATTR
      See Also:
    • XMLEND

      public static final int XMLEND
      See Also:
    • TO_OBJECT

      public static final int TO_OBJECT
      See Also:
    • TO_DOUBLE

      public static final int TO_DOUBLE
      See Also:
    • GET

      public static final int GET
      See Also:
    • SET

      public static final int SET
      See Also:
    • LET

      public static final int LET
      See Also:
    • CONST

      public static final int CONST
      See Also:
    • SETCONST

      public static final int SETCONST
      See Also:
    • SETCONSTVAR

      public static final int SETCONSTVAR
      See Also:
    • ARRAYCOMP

      public static final int ARRAYCOMP
      See Also:
    • LETEXPR

      public static final int LETEXPR
      See Also:
    • WITHEXPR

      public static final int WITHEXPR
      See Also:
    • DEBUGGER

      public static final int DEBUGGER
      See Also:
    • COMMENT

      public static final int COMMENT
      See Also:
    • GENEXPR

      public static final int GENEXPR
      See Also:
    • METHOD

      public static final int METHOD
      See Also:
    • ARROW

      public static final int ARROW
      See Also:
    • YIELD_STAR

      public static final int YIELD_STAR
      See Also:
    • TEMPLATE_LITERAL

      public static final int TEMPLATE_LITERAL
      See Also:
    • TEMPLATE_CHARS

      public static final int TEMPLATE_CHARS
      See Also:
    • TEMPLATE_LITERAL_SUBST

      public static final int TEMPLATE_LITERAL_SUBST
      See Also:
    • TAGGED_TEMPLATE_LITERAL

      public static final int TAGGED_TEMPLATE_LITERAL
      See Also:
    • DOTDOTDOT

      public static final int DOTDOTDOT
      See Also:
    • NULLISH_COALESCING

      public static final int NULLISH_COALESCING
      See Also:
    • QUESTION_DOT

      public static final int QUESTION_DOT
      See Also:
    • LAST_TOKEN

      public static final int LAST_TOKEN
      See Also:
  • Constructor Details

    • Token

      public Token()
  • Method Details

    • name

      public static 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 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 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