Chromium Code Reviews| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 T(ESCAPED_STRICT_RESERVED_WORD, NULL, 0) \ | 166 T(ESCAPED_STRICT_RESERVED_WORD, NULL, 0) \ |
| 165 \ | 167 \ |
| 166 /* Scanner-internal use only. */ \ | 168 /* Scanner-internal use only. */ \ |
| 167 T(WHITESPACE, NULL, 0) \ | 169 T(WHITESPACE, NULL, 0) \ |
| 168 T(UNINITIALIZED, NULL, 0) \ | 170 T(UNINITIALIZED, NULL, 0) \ |
| 169 \ | 171 \ |
| 170 /* ES6 Template Literals */ \ | 172 /* ES6 Template Literals */ \ |
| 171 T(TEMPLATE_SPAN, NULL, 0) \ | 173 T(TEMPLATE_SPAN, NULL, 0) \ |
| 172 T(TEMPLATE_TAIL, NULL, 0) | 174 T(TEMPLATE_TAIL, NULL, 0) |
| 173 | 175 |
| 174 | |
|
Dan Ehrenberg
2016/02/11 08:16:50
Why a change here?
| |
| 175 class Token { | 176 class Token { |
| 176 public: | 177 public: |
| 177 // All token values. | 178 // All token values. |
| 178 #define T(name, string, precedence) name, | 179 #define T(name, string, precedence) name, |
| 179 enum Value { | 180 enum Value { |
| 180 TOKEN_LIST(T, T) | 181 TOKEN_LIST(T, T) |
| 181 NUM_TOKENS | 182 NUM_TOKENS |
| 182 }; | 183 }; |
| 183 #undef T | 184 #undef T |
| 184 | 185 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 207 case YIELD: | 208 case YIELD: |
| 208 return !is_generator && is_sloppy(language_mode); | 209 return !is_generator && is_sloppy(language_mode); |
| 209 default: | 210 default: |
| 210 return false; | 211 return false; |
| 211 } | 212 } |
| 212 UNREACHABLE(); | 213 UNREACHABLE(); |
| 213 return false; | 214 return false; |
| 214 } | 215 } |
| 215 | 216 |
| 216 static bool IsAssignmentOp(Value tok) { | 217 static bool IsAssignmentOp(Value tok) { |
| 217 return INIT <= tok && tok <= ASSIGN_MOD; | 218 return INIT <= tok && tok <= ASSIGN_EXP; |
|
Dan Ehrenberg
2016/02/11 08:16:50
Maybe make constants expressing the start and end?
| |
| 218 } | 219 } |
| 219 | 220 |
| 220 static bool IsBinaryOp(Value op) { | 221 static bool IsBinaryOp(Value op) { return COMMA <= op && op <= EXP; } |
| 221 return COMMA <= op && op <= MOD; | |
| 222 } | |
| 223 | 222 |
| 224 static bool IsTruncatingBinaryOp(Value op) { | 223 static bool IsTruncatingBinaryOp(Value op) { |
| 225 return BIT_OR <= op && op <= ROR; | 224 return BIT_OR <= op && op <= ROR; |
| 226 } | 225 } |
| 227 | 226 |
| 228 static bool IsCompareOp(Value op) { | 227 static bool IsCompareOp(Value op) { |
| 229 return EQ <= op && op <= IN; | 228 return EQ <= op && op <= IN; |
| 230 } | 229 } |
| 231 | 230 |
| 232 static bool IsOrderedRelationalCompareOp(Value op) { | 231 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]; | 330 static const char* const name_[NUM_TOKENS]; |
| 332 static const char* const string_[NUM_TOKENS]; | 331 static const char* const string_[NUM_TOKENS]; |
| 333 static const int8_t precedence_[NUM_TOKENS]; | 332 static const int8_t precedence_[NUM_TOKENS]; |
| 334 static const char token_type[NUM_TOKENS]; | 333 static const char token_type[NUM_TOKENS]; |
| 335 }; | 334 }; |
| 336 | 335 |
| 337 } // namespace internal | 336 } // namespace internal |
| 338 } // namespace v8 | 337 } // namespace v8 |
| 339 | 338 |
| 340 #endif // V8_PARSING_TOKEN_H_ | 339 #endif // V8_PARSING_TOKEN_H_ |
| OLD | NEW |