2 * @fileoverview Contains token information.
3 * @author Nicholas C. Zakas
4 * @copyright 2014 Nicholas C. Zakas. All rights reserved.
5 * @copyright 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
6 * @copyright 2011-2013 Ariya Hidayat <ariya.hidayat@gmail.com>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 //------------------------------------------------------------------------------
33 //------------------------------------------------------------------------------
37 //------------------------------------------------------------------------------
39 //------------------------------------------------------------------------------
57 TokenName[Token.BooleanLiteral] = "Boolean";
58 TokenName[Token.EOF] = "<end>";
59 TokenName[Token.Identifier] = "Identifier";
60 TokenName[Token.Keyword] = "Keyword";
61 TokenName[Token.NullLiteral] = "Null";
62 TokenName[Token.NumericLiteral] = "Numeric";
63 TokenName[Token.Punctuator] = "Punctuator";
64 TokenName[Token.StringLiteral] = "String";
65 TokenName[Token.RegularExpression] = "RegularExpression";
66 TokenName[Token.Template] = "Template";
67 TokenName[Token.JSXIdentifier] = "JSXIdentifier";
68 TokenName[Token.JSXText] = "JSXText";
70 // A function following one of those tokens is an expression.
71 var FnExprTokens = ["(", "{", "[", "in", "typeof", "instanceof", "new",
72 "return", "case", "delete", "throw", "void",
73 // assignment operators
74 "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
75 "&=", "|=", "^=", ",",
76 // binary/unary operators
77 "+", "-", "*", "/", "%", "++", "--", "<<", ">>", ">>>", "&",
78 "|", "^", "!", "~", "&&", "||", "?", ":", "===", "==", ">=",
79 "<=", "<", ">", "!=", "!=="];
82 //------------------------------------------------------------------------------
84 //------------------------------------------------------------------------------
89 FnExprTokens: FnExprTokens