2 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef ParserTokens_h
27 #define ParserTokens_h
34 UnaryOpTokenFlag
= 64,
35 KeywordTokenFlag
= 128,
36 BinaryOpTokenPrecedenceShift
= 8,
37 BinaryOpTokenAllowsInPrecedenceAdditionalShift
= 4,
38 BinaryOpTokenPrecedenceMask
= 15 << BinaryOpTokenPrecedenceShift
,
41 #define BINARY_OP_PRECEDENCE(prec) (((prec) << BinaryOpTokenPrecedenceShift) | ((prec) << (BinaryOpTokenPrecedenceShift + BinaryOpTokenAllowsInPrecedenceAdditionalShift)))
42 #define IN_OP_PRECEDENCE(prec) ((prec) << (BinaryOpTokenPrecedenceShift + BinaryOpTokenAllowsInPrecedenceAdditionalShift))
45 NULLTOKEN
= KeywordTokenFlag
,
102 // Begin tagged tokens
103 PLUSPLUS
= 0 | UnaryOpTokenFlag
,
104 MINUSMINUS
= 1 | UnaryOpTokenFlag
,
105 EXCLAMATION
= 2 | UnaryOpTokenFlag
,
106 TILDE
= 3 | UnaryOpTokenFlag
,
107 AUTOPLUSPLUS
= 4 | UnaryOpTokenFlag
,
108 AUTOMINUSMINUS
= 5 | UnaryOpTokenFlag
,
109 TYPEOF
= 6 | UnaryOpTokenFlag
| KeywordTokenFlag
,
110 VOIDTOKEN
= 7 | UnaryOpTokenFlag
| KeywordTokenFlag
,
111 DELETETOKEN
= 8 | UnaryOpTokenFlag
| KeywordTokenFlag
,
112 OR
= 0 | BINARY_OP_PRECEDENCE(1),
113 AND
= 1 | BINARY_OP_PRECEDENCE(2),
114 BITOR
= 2 | BINARY_OP_PRECEDENCE(3),
115 BITXOR
= 3 | BINARY_OP_PRECEDENCE(4),
116 BITAND
= 4 | BINARY_OP_PRECEDENCE(5),
117 EQEQ
= 5 | BINARY_OP_PRECEDENCE(6),
118 NE
= 6 | BINARY_OP_PRECEDENCE(6),
119 STREQ
= 7 | BINARY_OP_PRECEDENCE(6),
120 STRNEQ
= 8 | BINARY_OP_PRECEDENCE(6),
121 LT
= 9 | BINARY_OP_PRECEDENCE(7),
122 GT
= 10 | BINARY_OP_PRECEDENCE(7),
123 LE
= 11 | BINARY_OP_PRECEDENCE(7),
124 GE
= 12 | BINARY_OP_PRECEDENCE(7),
125 INSTANCEOF
= 13 | BINARY_OP_PRECEDENCE(7) | KeywordTokenFlag
,
126 INTOKEN
= 14 | IN_OP_PRECEDENCE(7) | KeywordTokenFlag
,
127 LSHIFT
= 15 | BINARY_OP_PRECEDENCE(8),
128 RSHIFT
= 16 | BINARY_OP_PRECEDENCE(8),
129 URSHIFT
= 17 | BINARY_OP_PRECEDENCE(8),
130 PLUS
= 18 | BINARY_OP_PRECEDENCE(9) | UnaryOpTokenFlag
,
131 MINUS
= 19 | BINARY_OP_PRECEDENCE(9) | UnaryOpTokenFlag
,
132 TIMES
= 20 | BINARY_OP_PRECEDENCE(10),
133 DIVIDE
= 21 | BINARY_OP_PRECEDENCE(10),
134 MOD
= 22 | BINARY_OP_PRECEDENCE(10)
140 const Identifier
* ident
;
144 JSTokenInfo() : line(0) { }
156 enum JSParserStrictness
{ JSParseNormal
, JSParseStrict
};
157 enum JSParserMode
{ JSParseProgramCode
, JSParseFunctionCode
};
162 #endif // ParserTokens_h