|
|
@ -87,13 +87,8 @@ namespace solidity |
|
|
|
T(ARROW, "=>", 0) \ |
|
|
|
\ |
|
|
|
/* Assignment operators. */ \ |
|
|
|
/* IsAssignmentOp() and Assignment::is_compound() relies on */ \ |
|
|
|
/* this block of enum values being contiguous and sorted in the */ \ |
|
|
|
/* same order! */ \ |
|
|
|
T(INIT_VAR, "=init_var", 2) /* AST-use only. */ \ |
|
|
|
T(INIT_LET, "=init_let", 2) /* AST-use only. */ \ |
|
|
|
T(INIT_CONST, "=init_const", 2) /* AST-use only. */ \ |
|
|
|
T(INIT_CONST_LEGACY, "=init_const_legacy", 2) /* AST-use only. */ \ |
|
|
|
/* IsAssignmentOp() relies on this block of enum values being */ \ |
|
|
|
/* contiguous and sorted in the same order!*/ \ |
|
|
|
T(ASSIGN, "=", 2) \ |
|
|
|
/* The following have to be in exactly the same order as the simple binary operators*/ \ |
|
|
|
T(ASSIGN_BIT_OR, "|=", 2) \ |
|
|
@ -131,13 +126,10 @@ namespace solidity |
|
|
|
/* being contiguous and sorted in the same order! */ \ |
|
|
|
T(EQ, "==", 9) \ |
|
|
|
T(NE, "!=", 9) \ |
|
|
|
T(EQ_STRICT, "===", 9) \ |
|
|
|
T(NE_STRICT, "!==", 9) \ |
|
|
|
T(LT, "<", 10) \ |
|
|
|
T(GT, ">", 10) \ |
|
|
|
T(LTE, "<=", 10) \ |
|
|
|
T(GTE, ">=", 10) \ |
|
|
|
K(INSTANCEOF, "instanceof", 10) \ |
|
|
|
K(IN, "in", 10) \ |
|
|
|
\ |
|
|
|
/* Unary operators. */ \ |
|
|
@ -146,26 +138,21 @@ namespace solidity |
|
|
|
T(NOT, "!", 0) \ |
|
|
|
T(BIT_NOT, "~", 0) \ |
|
|
|
K(DELETE, "delete", 0) \ |
|
|
|
K(TYPEOF, "typeof", 0) \ |
|
|
|
K(VOID, "void", 0) \ |
|
|
|
\ |
|
|
|
/* Keywords (ECMA-262, section 7.5.2, page 13). */ \ |
|
|
|
/* Keywords */ \ |
|
|
|
K(BREAK, "break", 0) \ |
|
|
|
K(CASE, "case", 0) \ |
|
|
|
K(CATCH, "catch", 0) \ |
|
|
|
K(CONST, "const", 0) \ |
|
|
|
K(CONTINUE, "continue", 0) \ |
|
|
|
K(CONTRACT, "contract", 0) \ |
|
|
|
K(DEBUGGER, "debugger", 0) \ |
|
|
|
K(DEFAULT, "default", 0) \ |
|
|
|
/* DELETE */ \ |
|
|
|
K(DO, "do", 0) \ |
|
|
|
K(ELSE, "else", 0) \ |
|
|
|
K(FINALLY, "finally", 0) \ |
|
|
|
K(EXTENDS, "extends", 0) \ |
|
|
|
K(FOR, "for", 0) \ |
|
|
|
K(FUNCTION, "function", 0) \ |
|
|
|
K(IF, "if", 0) \ |
|
|
|
/* IN */ \ |
|
|
|
/* INSTANCEOF */ \ |
|
|
|
K(IMPORT, "import", 0) \ |
|
|
|
K(MAPPING, "mapping", 0) \ |
|
|
|
K(NEW, "new", 0) \ |
|
|
|
K(PUBLIC, "public", 0) \ |
|
|
@ -175,13 +162,9 @@ namespace solidity |
|
|
|
K(STRUCT, "struct", 0) \ |
|
|
|
K(SWITCH, "switch", 0) \ |
|
|
|
K(THIS, "this", 0) \ |
|
|
|
K(THROW, "throw", 0) \ |
|
|
|
K(TRY, "try", 0) \ |
|
|
|
/* TYPEOF */ \ |
|
|
|
K(VAR, "var", 0) \ |
|
|
|
/* VOID */ \ |
|
|
|
K(WHILE, "while", 0) \ |
|
|
|
K(WITH, "with", 0) \ |
|
|
|
\ |
|
|
|
\ |
|
|
|
/* type keywords, keep them in this order, keep int as first keyword
|
|
|
|
* the implementation in Types.cpp has to be synced to this here |
|
|
@ -209,7 +192,7 @@ namespace solidity |
|
|
|
K(UREAL, "ureal", 0) \ |
|
|
|
T(TYPES_END, NULL, 0) /* used as type enum end marker */ \ |
|
|
|
\ |
|
|
|
/* Literals (ECMA-262, section 7.8, page 16). */ \ |
|
|
|
/* Literals */ \ |
|
|
|
K(NULL_LITERAL, "null", 0) \ |
|
|
|
K(TRUE_LITERAL, "true", 0) \ |
|
|
|
K(FALSE_LITERAL, "false", 0) \ |
|
|
@ -219,19 +202,6 @@ namespace solidity |
|
|
|
/* Identifiers (not keywords or future reserved words). */ \ |
|
|
|
T(IDENTIFIER, NULL, 0) \ |
|
|
|
\ |
|
|
|
/* Future reserved words (ECMA-262, section 7.6.1.2). */ \ |
|
|
|
T(FUTURE_RESERVED_WORD, NULL, 0) \ |
|
|
|
T(FUTURE_STRICT_RESERVED_WORD, NULL, 0) \ |
|
|
|
K(CLASS, "class", 0) \ |
|
|
|
K(CONST, "const", 0) \ |
|
|
|
K(EXPORT, "export", 0) \ |
|
|
|
K(EXTENDS, "extends", 0) \ |
|
|
|
K(IMPORT, "import", 0) \ |
|
|
|
K(LET, "let", 0) \ |
|
|
|
K(STATIC, "static", 0) \ |
|
|
|
/* K(YIELD, "yield", 0) */ \ |
|
|
|
K(SUPER, "super", 0) \ |
|
|
|
\ |
|
|
|
/* Illegal token - not able to scan. */ \ |
|
|
|
T(ILLEGAL, "ILLEGAL", 0) \ |
|
|
|
\ |
|
|
@ -263,7 +233,7 @@ public: |
|
|
|
static bool isKeyword(Value tok) { return m_tokenType[tok] == 'K'; } |
|
|
|
static bool isIdentifier(Value tok) { return tok == IDENTIFIER; } |
|
|
|
static bool isElementaryTypeName(Value tok) { return INT <= tok && tok < TYPES_END; } |
|
|
|
static bool isAssignmentOp(Value tok) { return INIT_VAR <= tok && tok <= ASSIGN_MOD; } |
|
|
|
static bool isAssignmentOp(Value tok) { return ASSIGN <= tok && tok <= ASSIGN_MOD; } |
|
|
|
static bool isBinaryOp(Value op) { return COMMA <= op && op <= MOD; } |
|
|
|
static bool isTruncatingBinaryOp(Value op) { return BIT_OR <= op && op <= SHR; } |
|
|
|
static bool isCompareOp(Value op) { return EQ <= op && op <= IN; } |
|
|
@ -271,8 +241,8 @@ public: |
|
|
|
{ |
|
|
|
return op == LT || op == LTE || op == GT || op == GTE; |
|
|
|
} |
|
|
|
static bool isEqualityOp(Value op) { return op == EQ || op == EQ_STRICT; } |
|
|
|
static bool isInequalityOp(Value op) { return op == NE || op == NE_STRICT; } |
|
|
|
static bool isEqualityOp(Value op) { return op == EQ; } |
|
|
|
static bool isInequalityOp(Value op) { return op == NE; } |
|
|
|
static bool isArithmeticCompareOp(Value op) |
|
|
|
{ |
|
|
|
return isOrderedRelationalCompareOp(op) || |
|
|
@ -288,10 +258,6 @@ public: |
|
|
|
return NE; |
|
|
|
case NE: |
|
|
|
return EQ; |
|
|
|
case EQ_STRICT: |
|
|
|
return NE_STRICT; |
|
|
|
case NE_STRICT: |
|
|
|
return EQ_STRICT; |
|
|
|
case LT: |
|
|
|
return GTE; |
|
|
|
case GT: |
|
|
@ -315,10 +281,6 @@ public: |
|
|
|
return EQ; |
|
|
|
case NE: |
|
|
|
return NE; |
|
|
|
case EQ_STRICT: |
|
|
|
return EQ_STRICT; |
|
|
|
case NE_STRICT: |
|
|
|
return NE_STRICT; |
|
|
|
case LT: |
|
|
|
return GT; |
|
|
|
case GT: |
|
|
@ -340,7 +302,7 @@ public: |
|
|
|
} |
|
|
|
|
|
|
|
static bool isBitOp(Value op) { return (BIT_OR <= op && op <= SHR) || op == BIT_NOT; } |
|
|
|
static bool isUnaryOp(Value op) { return (NOT <= op && op <= VOID) || op == ADD || op == SUB; } |
|
|
|
static bool isUnaryOp(Value op) { return (NOT <= op && op <= DELETE) || op == ADD || op == SUB; } |
|
|
|
static bool isCountOp(Value op) { return op == INC || op == DEC; } |
|
|
|
static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } |
|
|
|
|
|
|
|