org.mozilla.javascript

Class 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.
Authors:
Mike McCabe
Brendan Eich
See Also:
Parser

Field Summary

static int
ADD
Token types.
static int
AND
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
CONTINUE
static int
DEC
static int
DEFAULT
static int
DEFAULTNAMESPACE
Token types.
static int
DELPROP
Token types.
static int
DEL_REF
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_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
GETELEM
Token types.
static int
GETPROP
Token types.
static int
GETVAR
Token types.
static int
GET_REF
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
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 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
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
SET_REF
Token types.
static int
SET_REF_OP
static int
SHEQ
Token types.
static int
SHNE
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
XML
static int
XMLATTR
static int
XMLEND
static boolean
printTrees

Method Summary

static String
name(int token)

Field Details

ADD

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

AND

public static final int AND
Field Value:
101

ARRAYLIT

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

ASSIGN

public static final int ASSIGN
Field Value:
86

ASSIGN_ADD

public static final int ASSIGN_ADD
Field Value:
93

ASSIGN_BITAND

public static final int ASSIGN_BITAND
Field Value:
89

ASSIGN_BITOR

public static final int ASSIGN_BITOR
Field Value:
87

ASSIGN_BITXOR

public static final int ASSIGN_BITXOR
Field Value:
88

ASSIGN_DIV

public static final int ASSIGN_DIV
Field Value:
96

ASSIGN_LSH

public static final int ASSIGN_LSH
Field Value:
90

ASSIGN_MOD

public static final int ASSIGN_MOD
Field Value:
97

ASSIGN_MUL

public static final int ASSIGN_MUL
Field Value:
95

ASSIGN_RSH

public static final int ASSIGN_RSH
Field Value:
91

ASSIGN_SUB

public static final int ASSIGN_SUB
Field Value:
94

ASSIGN_URSH

public static final int ASSIGN_URSH
Field Value:
92

BINDNAME

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

BITAND

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

BITNOT

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

BITOR

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

BITXOR

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

BLOCK

public static final int BLOCK
Field Value:
125

BREAK

public static final int BREAK
Field Value:
116

CALL

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

CASE

public static final int CASE
Field Value:
111

CATCH

public static final int CATCH
Field Value:
120

CATCH_SCOPE

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

COLON

public static final int COLON
Field Value:
99

COLONCOLON

public static final int COLONCOLON
Field Value:
140

COMMA

public static final int COMMA
Field Value:
85

CONTINUE

public static final int CONTINUE
Field Value:
117

DEC

public static final int DEC
Field Value:
103

DEFAULT

public static final int DEFAULT
Field Value:
112

DEFAULTNAMESPACE

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

DELPROP

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

DEL_REF

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

DIV

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

DO

public static final int DO
Field Value:
114

DOT

public static final int DOT
Field Value:
104

DOTDOT

public static final int DOTDOT
Field Value:
139

DOTQUERY

public static final int DOTQUERY
Field Value:
142

ELSE

public static final int ELSE
Field Value:
109

EMPTY

public static final int EMPTY
Field Value:
124

ENTERWITH

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

ENUM_ID

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

ENUM_INIT_KEYS

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

ENUM_INIT_VALUES

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

ENUM_NEXT

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

EOF

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

EOL

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

EQ

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

ERROR

public static final int ERROR
Token types. These values correspond to JSTokenType values in jsscan.c.
Field Value:
-1

ESCXMLATTR

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

ESCXMLTEXT

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

EXPORT

public static final int EXPORT
Field Value:
106

EXPR_RESULT

public static final int EXPR_RESULT
Field Value:
130

EXPR_VOID

public static final int EXPR_VOID
Field Value:
129

FALSE

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

FINALLY

public static final int FINALLY
Field Value:
121

FIRST_ASSIGN

public static final int FIRST_ASSIGN
Field Value:
86

FIRST_BYTECODE_TOKEN

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

FOR

public static final int FOR
Field Value:
115

FUNCTION

public static final int FUNCTION
Field Value:
105

GE

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

GETELEM

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

GETPROP

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

GETVAR

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

GET_REF

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

GOTO

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

GT

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

HOOK

public static final int HOOK
Field Value:
98

IF

public static final int IF
Field Value:
108

IFEQ

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

IFNE

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

IMPORT

public static final int IMPORT
Field Value:
107

IN

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

INC

public static final int INC
Field Value:
102

INSTANCEOF

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

JSR

public static final int JSR
Field Value:
131

LABEL

public static final int LABEL
Field Value:
126

LAST_ASSIGN

public static final int LAST_ASSIGN
Field Value:
97

LAST_BYTECODE_TOKEN

public static final int LAST_BYTECODE_TOKEN
Field Value:
76

LAST_TOKEN

public static final int LAST_TOKEN
Field Value:
146

LB

public static final int LB
Field Value:
79

LC

public static final int LC
Field Value:
81

LE

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

LEAVEWITH

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

LOCAL_BLOCK

public static final int LOCAL_BLOCK
Field Value:
137

LOCAL_LOAD

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

LOOP

public static final int LOOP
Field Value:
128

LP

public static final int LP
Field Value:
83

LSH

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

LT

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

MOD

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

MUL

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

NAME

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

NE

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

NEG

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

NEW

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

NOT

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

NULL

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

NUMBER

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

OBJECTLIT

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

OR

public static final int OR
Field Value:
100

POS

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

RB

public static final int RB
Field Value:
80

RC

public static final int RC
Field Value:
82

REF_CALL

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

REF_MEMBER

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

REF_NAME

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

REF_NS_MEMBER

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

REF_NS_NAME

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

REF_SPECIAL

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

REGEXP

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

RESERVED

public static final int RESERVED
Field Value:
123

RETHROW

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

RETURN

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

RETURN_RESULT

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

RP

public static final int RP
Field Value:
84

RSH

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

SCRIPT

public static final int SCRIPT
Field Value:
132

SEMI

public static final int SEMI
Field Value:
78

SETELEM

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

SETELEM_OP

public static final int SETELEM_OP
Field Value:
136

SETNAME

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

SETPROP

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

SETPROP_OP

public static final int SETPROP_OP
Field Value:
135

SETVAR

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

SET_REF

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

SET_REF_OP

public static final int SET_REF_OP
Field Value:
138

SHEQ

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

SHNE

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

STRING

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

SUB

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

SWITCH

public static final int SWITCH
Field Value:
110

TARGET

public static final int TARGET
Field Value:
127

THIS

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

THISFN

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

THROW

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

TO_DOUBLE

public static final int TO_DOUBLE
Field Value:
146

TO_OBJECT

public static final int TO_OBJECT
Field Value:
145

TRUE

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

TRY

public static final int TRY
Field Value:
77

TYPEOF

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

TYPEOFNAME

public static final int TYPEOFNAME
Field Value:
133

URSH

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

USE_STACK

public static final int USE_STACK
Field Value:
134

VAR

public static final int VAR
Field Value:
118

VOID

public static final int VOID
Field Value:
122

WHILE

public static final int WHILE
Field Value:
113

WITH

public static final int WITH
Field Value:
119

XML

public static final int XML
Field Value:
141

XMLATTR

public static final int XMLATTR
Field Value:
143

XMLEND

public static final int XMLEND
Field Value:
144

printTrees

public static final boolean printTrees
Field Value:
false

Method Details

name

public static String name(int token)