OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PARSING_TOKEN_H_ | 5 #ifndef V8_PARSING_TOKEN_H_ |
6 #define V8_PARSING_TOKEN_H_ | 6 #define V8_PARSING_TOKEN_H_ |
7 | 7 |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/globals.h" | 9 #include "src/globals.h" |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 T(ASSIGN_BIT_XOR, "^=", 2) \ | 56 T(ASSIGN_BIT_XOR, "^=", 2) \ |
57 T(ASSIGN_BIT_AND, "&=", 2) \ | 57 T(ASSIGN_BIT_AND, "&=", 2) \ |
58 T(ASSIGN_SHL, "<<=", 2) \ | 58 T(ASSIGN_SHL, "<<=", 2) \ |
59 T(ASSIGN_SAR, ">>=", 2) \ | 59 T(ASSIGN_SAR, ">>=", 2) \ |
60 T(ASSIGN_SHR, ">>>=", 2) \ | 60 T(ASSIGN_SHR, ">>>=", 2) \ |
61 T(ASSIGN_ADD, "+=", 2) \ | 61 T(ASSIGN_ADD, "+=", 2) \ |
62 T(ASSIGN_SUB, "-=", 2) \ | 62 T(ASSIGN_SUB, "-=", 2) \ |
63 T(ASSIGN_MUL, "*=", 2) \ | 63 T(ASSIGN_MUL, "*=", 2) \ |
64 T(ASSIGN_DIV, "/=", 2) \ | 64 T(ASSIGN_DIV, "/=", 2) \ |
65 T(ASSIGN_MOD, "%=", 2) \ | 65 T(ASSIGN_MOD, "%=", 2) \ |
| 66 T(ASSIGN_EXP, "**=", 2) \ |
66 \ | 67 \ |
67 /* Binary operators sorted by precedence. */ \ | 68 /* Binary operators sorted by precedence. */ \ |
68 /* IsBinaryOp() relies on this block of enum values */ \ | 69 /* IsBinaryOp() relies on this block of enum values */ \ |
69 /* being contiguous and sorted in the same order! */ \ | 70 /* being contiguous and sorted in the same order! */ \ |
70 T(COMMA, ",", 1) \ | 71 T(COMMA, ",", 1) \ |
71 T(OR, "||", 4) \ | 72 T(OR, "||", 4) \ |
72 T(AND, "&&", 5) \ | 73 T(AND, "&&", 5) \ |
73 T(BIT_OR, "|", 6) \ | 74 T(BIT_OR, "|", 6) \ |
74 T(BIT_XOR, "^", 7) \ | 75 T(BIT_XOR, "^", 7) \ |
75 T(BIT_AND, "&", 8) \ | 76 T(BIT_AND, "&", 8) \ |
76 T(SHL, "<<", 11) \ | 77 T(SHL, "<<", 11) \ |
77 T(SAR, ">>", 11) \ | 78 T(SAR, ">>", 11) \ |
78 T(SHR, ">>>", 11) \ | 79 T(SHR, ">>>", 11) \ |
79 T(ROR, "rotate right", 11) /* only used by Crankshaft */ \ | 80 T(ROR, "rotate right", 11) /* only used by Crankshaft */ \ |
80 T(ADD, "+", 12) \ | 81 T(ADD, "+", 12) \ |
81 T(SUB, "-", 12) \ | 82 T(SUB, "-", 12) \ |
82 T(MUL, "*", 13) \ | 83 T(MUL, "*", 13) \ |
83 T(DIV, "/", 13) \ | 84 T(DIV, "/", 13) \ |
84 T(MOD, "%", 13) \ | 85 T(MOD, "%", 13) \ |
| 86 T(EXP, "**", 14) \ |
85 \ | 87 \ |
86 /* Compare operators sorted by precedence. */ \ | 88 /* Compare operators sorted by precedence. */ \ |
87 /* IsCompareOp() relies on this block of enum values */ \ | 89 /* IsCompareOp() relies on this block of enum values */ \ |
88 /* being contiguous and sorted in the same order! */ \ | 90 /* being contiguous and sorted in the same order! */ \ |
89 T(EQ, "==", 9) \ | 91 T(EQ, "==", 9) \ |
90 T(NE, "!=", 9) \ | 92 T(NE, "!=", 9) \ |
91 T(EQ_STRICT, "===", 9) \ | 93 T(EQ_STRICT, "===", 9) \ |
92 T(NE_STRICT, "!==", 9) \ | 94 T(NE_STRICT, "!==", 9) \ |
93 T(LT, "<", 10) \ | 95 T(LT, "<", 10) \ |
94 T(GT, ">", 10) \ | 96 T(GT, ">", 10) \ |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 case YIELD: | 209 case YIELD: |
208 return !is_generator && is_sloppy(language_mode); | 210 return !is_generator && is_sloppy(language_mode); |
209 default: | 211 default: |
210 return false; | 212 return false; |
211 } | 213 } |
212 UNREACHABLE(); | 214 UNREACHABLE(); |
213 return false; | 215 return false; |
214 } | 216 } |
215 | 217 |
216 static bool IsAssignmentOp(Value tok) { | 218 static bool IsAssignmentOp(Value tok) { |
217 return INIT <= tok && tok <= ASSIGN_MOD; | 219 return INIT <= tok && tok <= ASSIGN_EXP; |
218 } | 220 } |
219 | 221 |
220 static bool IsBinaryOp(Value op) { | 222 static bool IsBinaryOp(Value op) { return COMMA <= op && op <= EXP; } |
221 return COMMA <= op && op <= MOD; | |
222 } | |
223 | 223 |
224 static bool IsTruncatingBinaryOp(Value op) { | 224 static bool IsTruncatingBinaryOp(Value op) { |
225 return BIT_OR <= op && op <= ROR; | 225 return BIT_OR <= op && op <= ROR; |
226 } | 226 } |
227 | 227 |
228 static bool IsCompareOp(Value op) { | 228 static bool IsCompareOp(Value op) { |
229 return EQ <= op && op <= IN; | 229 return EQ <= op && op <= IN; |
230 } | 230 } |
231 | 231 |
232 static bool IsOrderedRelationalCompareOp(Value op) { | 232 static bool IsOrderedRelationalCompareOp(Value op) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 static const char* const name_[NUM_TOKENS]; | 331 static const char* const name_[NUM_TOKENS]; |
332 static const char* const string_[NUM_TOKENS]; | 332 static const char* const string_[NUM_TOKENS]; |
333 static const int8_t precedence_[NUM_TOKENS]; | 333 static const int8_t precedence_[NUM_TOKENS]; |
334 static const char token_type[NUM_TOKENS]; | 334 static const char token_type[NUM_TOKENS]; |
335 }; | 335 }; |
336 | 336 |
337 } // namespace internal | 337 } // namespace internal |
338 } // namespace v8 | 338 } // namespace v8 |
339 | 339 |
340 #endif // V8_PARSING_TOKEN_H_ | 340 #endif // V8_PARSING_TOKEN_H_ |
OLD | NEW |