aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/robertkrimen/otto/token/README.markdown
blob: ff3b16104030882769f46aaa7dacb1b24d7a8a05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# token
--
    import "github.com/robertkrimen/otto/token"

Package token defines constants representing the lexical tokens of JavaScript
(ECMA5).

## Usage

```go
const (
    ILLEGAL
    EOF
    COMMENT
    KEYWORD

    STRING
    BOOLEAN
    NULL
    NUMBER
    IDENTIFIER

    PLUS      // +
    MINUS     // -
    MULTIPLY  // *
    SLASH     // /
    REMAINDER // %

    AND                  // &
    OR                   // |
    EXCLUSIVE_OR         // ^
    SHIFT_LEFT           // <<
    SHIFT_RIGHT          // >>
    UNSIGNED_SHIFT_RIGHT // >>>
    AND_NOT              // &^

    ADD_ASSIGN       // +=
    SUBTRACT_ASSIGN  // -=
    MULTIPLY_ASSIGN  // *=
    QUOTIENT_ASSIGN  // /=
    REMAINDER_ASSIGN // %=

    AND_ASSIGN                  // &=
    OR_ASSIGN                   // |=
    EXCLUSIVE_OR_ASSIGN         // ^=
    SHIFT_LEFT_ASSIGN           // <<=
    SHIFT_RIGHT_ASSIGN          // >>=
    UNSIGNED_SHIFT_RIGHT_ASSIGN // >>>=
    AND_NOT_ASSIGN              // &^=

    LOGICAL_AND // &&
    LOGICAL_OR  // ||
    INCREMENT   // ++
    DECREMENT   // --

    EQUAL        // ==
    STRICT_EQUAL // ===
    LESS         // <
    GREATER      // >
    ASSIGN       // =
    NOT          // !

    BITWISE_NOT // ~

    NOT_EQUAL        // !=
    STRICT_NOT_EQUAL // !==
    LESS_OR_EQUAL    // <=
    GREATER_OR_EQUAL // >=

    LEFT_PARENTHESIS // (
    LEFT_BRACKET     // [
    LEFT_BRACE       // {
    COMMA            // ,
    PERIOD           // .

    RIGHT_PARENTHESIS // )
    RIGHT_BRACKET     // ]
    RIGHT_BRACE       // }
    SEMICOLON         // ;
    COLON             // :
    QUESTION_MARK     // ?

    IF
    IN
    DO

    VAR
    FOR
    NEW
    TRY

    THIS
    ELSE
    CASE
    VOID
    WITH

    WHILE
    BREAK
    CATCH
    THROW

    RETURN
    TYPEOF
    DELETE
    SWITCH

    DEFAULT
    FINALLY

    FUNCTION
    CONTINUE
    DEBUGGER

    INSTANCEOF
)
```

#### type Token

```go
type Token int
```

Token is the set of lexical tokens in JavaScript (ECMA5).

#### func  IsKeyword

```go
func IsKeyword(literal string) (Token, bool)
```
IsKeyword returns the keyword token if literal is a keyword, a KEYWORD token if
the literal is a future keyword (const, let, class, super, ...), or 0 if the
literal is not a keyword.

If the literal is a keyword, IsKeyword returns a second value indicating if the
literal is considered a future keyword in strict-mode only.

7.6.1.2 Future Reserved Words:

    const
    class
    enum
    export
    extends
    import
    super

7.6.1.2 Future Reserved Words (strict):

    implements
    interface
    let
    package
    private
    protected
    public
    static

#### func (Token) String

```go
func (tkn Token) String() string
```
String returns the string corresponding to the token. For operators, delimiters,
and keywords the string is the actual token string (e.g., for the token PLUS,
the String() is "+"). For all other tokens the string corresponds to the token
name (e.g. for the token IDENTIFIER, the string is "IDENTIFIER").

--
**godocdown** http://github.com/robertkrimen/godocdown