| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_TOKEN_H_ | 5 #ifndef VM_TOKEN_H_ |
| 6 #define VM_TOKEN_H_ | 6 #define VM_TOKEN_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 // Operator precedence table | 12 // Operator precedence table |
| 13 // | 13 // |
| 14 // 13 multiplicative * / ~/ % | 14 // 13 multiplicative * / ~/ % |
| 15 // 12 additive + - | 15 // 12 additive + - |
| 16 // 11 shift << >> | 16 // 11 shift << >> |
| 17 // 10 relational >= > <= < is as | 17 // 10 bitwise and & |
| 18 // 9 equality == != === !== | 18 // 9 bitwise xor ^ |
| 19 // 8 bitwise and & | 19 // 8 bitwise or | |
| 20 // 7 bitwise xor ^ | 20 // 7 relational >= > <= < is as |
| 21 // 6 bitwise or | | 21 // 6 equality == != === !== |
| 22 // 5 logical and && | 22 // 5 logical and && |
| 23 // 4 logical or || | 23 // 4 logical or || |
| 24 // 3 conditional ? | 24 // 3 conditional ? |
| 25 // 2 assignment = *= /= ~/= %= += -= <<= >>= &= ^= |= | 25 // 2 assignment = *= /= ~/= %= += -= <<= >>= &= ^= |= |
| 26 // 1 comma , | 26 // 1 comma , |
| 27 | 27 |
| 28 | 28 |
| 29 // Token definitions. | 29 // Token definitions. |
| 30 // Some operator tokens appear in blocks, e.g. assignment operators. | 30 // Some operator tokens appear in blocks, e.g. assignment operators. |
| 31 // There is code that depends on the values within a block to be | 31 // There is code that depends on the values within a block to be |
| (...skipping 28 matching lines...) Expand all Loading... |
| 60 TOK(kASSIGN_MUL, "*=", 2, kNoAttribute) \ | 60 TOK(kASSIGN_MUL, "*=", 2, kNoAttribute) \ |
| 61 TOK(kASSIGN_TRUNCDIV, "~/=", 2, kNoAttribute) \ | 61 TOK(kASSIGN_TRUNCDIV, "~/=", 2, kNoAttribute) \ |
| 62 TOK(kASSIGN_DIV, "/=", 2, kNoAttribute) \ | 62 TOK(kASSIGN_DIV, "/=", 2, kNoAttribute) \ |
| 63 TOK(kASSIGN_MOD, "%=", 2, kNoAttribute) \ | 63 TOK(kASSIGN_MOD, "%=", 2, kNoAttribute) \ |
| 64 \ | 64 \ |
| 65 TOK(kCASCADE, "..", 2, kNoAttribute) \ | 65 TOK(kCASCADE, "..", 2, kNoAttribute) \ |
| 66 \ | 66 \ |
| 67 TOK(kCOMMA, ",", 1, kNoAttribute) \ | 67 TOK(kCOMMA, ",", 1, kNoAttribute) \ |
| 68 TOK(kOR, "||", 4, kNoAttribute) \ | 68 TOK(kOR, "||", 4, kNoAttribute) \ |
| 69 TOK(kAND, "&&", 5, kNoAttribute) \ | 69 TOK(kAND, "&&", 5, kNoAttribute) \ |
| 70 TOK(kBIT_OR, "|", 6, kNoAttribute) \ | 70 TOK(kBIT_OR, "|", 8, kNoAttribute) \ |
| 71 TOK(kBIT_XOR, "^", 7, kNoAttribute) \ | 71 TOK(kBIT_XOR, "^", 9, kNoAttribute) \ |
| 72 TOK(kBIT_AND, "&", 8, kNoAttribute) \ | 72 TOK(kBIT_AND, "&", 10, kNoAttribute) \ |
| 73 TOK(kBIT_NOT, "~", 0, kNoAttribute) \ | 73 TOK(kBIT_NOT, "~", 0, kNoAttribute) \ |
| 74 \ | 74 \ |
| 75 /* Shift operators. */ \ | 75 /* Shift operators. */ \ |
| 76 TOK(kSHL, "<<", 11, kNoAttribute) \ | 76 TOK(kSHL, "<<", 11, kNoAttribute) \ |
| 77 TOK(kSHR, ">>", 11, kNoAttribute) \ | 77 TOK(kSHR, ">>", 11, kNoAttribute) \ |
| 78 \ | 78 \ |
| 79 /* Additive operators. */ \ | 79 /* Additive operators. */ \ |
| 80 TOK(kADD, "+", 12, kNoAttribute) \ | 80 TOK(kADD, "+", 12, kNoAttribute) \ |
| 81 TOK(kSUB, "-", 12, kNoAttribute) \ | 81 TOK(kSUB, "-", 12, kNoAttribute) \ |
| 82 \ | 82 \ |
| 83 /* Multiplicative operators */ \ | 83 /* Multiplicative operators */ \ |
| 84 TOK(kMUL, "*", 13, kNoAttribute) \ | 84 TOK(kMUL, "*", 13, kNoAttribute) \ |
| 85 TOK(kDIV, "/", 13, kNoAttribute) \ | 85 TOK(kDIV, "/", 13, kNoAttribute) \ |
| 86 TOK(kTRUNCDIV, "~/", 13, kNoAttribute) \ | 86 TOK(kTRUNCDIV, "~/", 13, kNoAttribute) \ |
| 87 TOK(kMOD, "%", 13, kNoAttribute) \ | 87 TOK(kMOD, "%", 13, kNoAttribute) \ |
| 88 \ | 88 \ |
| 89 TOK(kNOT, "!", 0, kNoAttribute) \ | 89 TOK(kNOT, "!", 0, kNoAttribute) \ |
| 90 TOK(kCONDITIONAL, "?", 3, kNoAttribute) \ | 90 TOK(kCONDITIONAL, "?", 3, kNoAttribute) \ |
| 91 \ | 91 \ |
| 92 /* Equality operators. */ \ | 92 /* Equality operators. */ \ |
| 93 /* Please update IsEqualityOperator() if you make */ \ | 93 /* Please update IsEqualityOperator() if you make */ \ |
| 94 /* any changes to this block. */ \ | 94 /* any changes to this block. */ \ |
| 95 TOK(kEQ, "==", 9, kNoAttribute) \ | 95 TOK(kEQ, "==", 6, kNoAttribute) \ |
| 96 TOK(kNE, "!=", 9, kNoAttribute) \ | 96 TOK(kNE, "!=", 6, kNoAttribute) \ |
| 97 TOK(kEQ_STRICT, "===", 9, kNoAttribute) \ | 97 TOK(kEQ_STRICT, "===", 6, kNoAttribute) \ |
| 98 TOK(kNE_STRICT, "!==", 9, kNoAttribute) \ | 98 TOK(kNE_STRICT, "!==", 6, kNoAttribute) \ |
| 99 \ | 99 \ |
| 100 /* Relational operators. */ \ | 100 /* Relational operators. */ \ |
| 101 /* Please update IsRelationalOperator() if you make */ \ | 101 /* Please update IsRelationalOperator() if you make */ \ |
| 102 /* any changes to this block. */ \ | 102 /* any changes to this block. */ \ |
| 103 TOK(kLT, "<", 10, kNoAttribute) \ | 103 TOK(kLT, "<", 7, kNoAttribute) \ |
| 104 TOK(kGT, ">", 10, kNoAttribute) \ | 104 TOK(kGT, ">", 7, kNoAttribute) \ |
| 105 TOK(kLTE, "<=", 10, kNoAttribute) \ | 105 TOK(kLTE, "<=", 7, kNoAttribute) \ |
| 106 TOK(kGTE, ">=", 10, kNoAttribute) \ | 106 TOK(kGTE, ">=", 7, kNoAttribute) \ |
| 107 \ | 107 \ |
| 108 /* Internal token for !(expr is Type) negative type test operator */ \ | 108 /* Internal token for !(expr is Type) negative type test operator */ \ |
| 109 TOK(kISNOT, "", 10, kNoAttribute) \ | 109 TOK(kISNOT, "", 10, kNoAttribute) \ |
| 110 \ | 110 \ |
| 111 /* Internal token for (expr as Type) type cast operator */ \ | 111 /* Internal token for (expr as Type) type cast operator */ \ |
| 112 TOK(kAS, "", 10, kNoAttribute) \ | 112 TOK(kAS, "", 10, kNoAttribute) \ |
| 113 \ | 113 \ |
| 114 TOK(kINDEX, "[]", 0, kNoAttribute) \ | 114 TOK(kINDEX, "[]", 0, kNoAttribute) \ |
| 115 TOK(kASSIGN_INDEX, "[]=", 0, kNoAttribute) \ | 115 TOK(kASSIGN_INDEX, "[]=", 0, kNoAttribute) \ |
| 116 TOK(kNEGATE, "unary-", 0, kNoAttribute) \ | 116 TOK(kNEGATE, "unary-", 0, kNoAttribute) \ |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 static const char* name_[]; | 311 static const char* name_[]; |
| 312 static const char* tok_str_[]; | 312 static const char* tok_str_[]; |
| 313 static const uint8_t precedence_[]; | 313 static const uint8_t precedence_[]; |
| 314 static const Attribute attributes_[]; | 314 static const Attribute attributes_[]; |
| 315 }; | 315 }; |
| 316 | 316 |
| 317 | 317 |
| 318 } // namespace dart | 318 } // namespace dart |
| 319 | 319 |
| 320 #endif // VM_TOKEN_H_ | 320 #endif // VM_TOKEN_H_ |
| OLD | NEW |