...
1# token
2--
3 import "github.com/dop251/goja/token"
4
5Package token defines constants representing the lexical tokens of JavaScript
6(ECMA5).
7
8## Usage
9
10```go
11const (
12 ILLEGAL
13 EOF
14 COMMENT
15 KEYWORD
16
17 STRING
18 BOOLEAN
19 NULL
20 NUMBER
21 IDENTIFIER
22
23 PLUS // +
24 MINUS // -
25 MULTIPLY // *
26 SLASH // /
27 REMAINDER // %
28
29 AND // &
30 OR // |
31 EXCLUSIVE_OR // ^
32 SHIFT_LEFT // <<
33 SHIFT_RIGHT // >>
34 UNSIGNED_SHIFT_RIGHT // >>>
35 AND_NOT // &^
36
37 ADD_ASSIGN // +=
38 SUBTRACT_ASSIGN // -=
39 MULTIPLY_ASSIGN // *=
40 QUOTIENT_ASSIGN // /=
41 REMAINDER_ASSIGN // %=
42
43 AND_ASSIGN // &=
44 OR_ASSIGN // |=
45 EXCLUSIVE_OR_ASSIGN // ^=
46 SHIFT_LEFT_ASSIGN // <<=
47 SHIFT_RIGHT_ASSIGN // >>=
48 UNSIGNED_SHIFT_RIGHT_ASSIGN // >>>=
49 AND_NOT_ASSIGN // &^=
50
51 LOGICAL_AND // &&
52 LOGICAL_OR // ||
53 INCREMENT // ++
54 DECREMENT // --
55
56 EQUAL // ==
57 STRICT_EQUAL // ===
58 LESS // <
59 GREATER // >
60 ASSIGN // =
61 NOT // !
62
63 BITWISE_NOT // ~
64
65 NOT_EQUAL // !=
66 STRICT_NOT_EQUAL // !==
67 LESS_OR_EQUAL // <=
68 GREATER_OR_EQUAL // >=
69
70 LEFT_PARENTHESIS // (
71 LEFT_BRACKET // [
72 LEFT_BRACE // {
73 COMMA // ,
74 PERIOD // .
75
76 RIGHT_PARENTHESIS // )
77 RIGHT_BRACKET // ]
78 RIGHT_BRACE // }
79 SEMICOLON // ;
80 COLON // :
81 QUESTION_MARK // ?
82
83 IF
84 IN
85 DO
86
87 VAR
88 FOR
89 NEW
90 TRY
91
92 THIS
93 ELSE
94 CASE
95 VOID
96 WITH
97
98 WHILE
99 BREAK
100 CATCH
101 THROW
102
103 RETURN
104 TYPEOF
105 DELETE
106 SWITCH
107
108 DEFAULT
109 FINALLY
110
111 FUNCTION
112 CONTINUE
113 DEBUGGER
114
115 INSTANCEOF
116)
117```
118
119#### type Token
120
121```go
122type Token int
123```
124
125Token is the set of lexical tokens in JavaScript (ECMA5).
126
127#### func IsKeyword
128
129```go
130func IsKeyword(literal string) (Token, bool)
131```
132IsKeyword returns the keyword token if literal is a keyword, a KEYWORD token if
133the literal is a future keyword (const, let, class, super, ...), or 0 if the
134literal is not a keyword.
135
136If the literal is a keyword, IsKeyword returns a second value indicating if the
137literal is considered a future keyword in strict-mode only.
138
1397.6.1.2 Future Reserved Words:
140
141 const
142 class
143 enum
144 export
145 extends
146 import
147 super
148
1497.6.1.2 Future Reserved Words (strict):
150
151 implements
152 interface
153 let
154 package
155 private
156 protected
157 public
158 static
159
160#### func (Token) String
161
162```go
163func (tkn Token) String() string
164```
165String returns the string corresponding to the token. For operators, delimiters,
166and keywords the string is the actual token string (e.g., for the token PLUS,
167the String() is "+"). For all other tokens the string corresponds to the token
168name (e.g. for the token IDENTIFIER, the string is "IDENTIFIER").
169
170--
171**godocdown** http://github.com/robertkrimen/godocdown
View as plain text