diff options
author | Christian <c@ethdev.com> | 2014-10-17 18:52:39 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2014-10-17 18:52:39 +0800 |
commit | 646f106a34f189b225745a079fdc8560b9230e68 (patch) | |
tree | 956670d7913533c3747405bea749a03e110af96f | |
parent | a7f9815c0f68a7cb9571193ded851fbedb418422 (diff) | |
download | dexon-solidity-646f106a34f189b225745a079fdc8560b9230e68.tar dexon-solidity-646f106a34f189b225745a079fdc8560b9230e68.tar.gz dexon-solidity-646f106a34f189b225745a079fdc8560b9230e68.tar.bz2 dexon-solidity-646f106a34f189b225745a079fdc8560b9230e68.tar.lz dexon-solidity-646f106a34f189b225745a079fdc8560b9230e68.tar.xz dexon-solidity-646f106a34f189b225745a079fdc8560b9230e68.tar.zst dexon-solidity-646f106a34f189b225745a079fdc8560b9230e68.zip |
Keyword cleanup
-rw-r--r-- | Scanner.cpp | 17 | ||||
-rw-r--r-- | Token.h | 62 |
2 files changed, 14 insertions, 65 deletions
diff --git a/Scanner.cpp b/Scanner.cpp index 61f56f29..236498fd 100644 --- a/Scanner.cpp +++ b/Scanner.cpp @@ -137,7 +137,7 @@ Token::Value Scanner::selectToken(char _next, Token::Value _then, Token::Value _ { advance(); if (m_char == _next) - selectToken(_then); + return selectToken(_then); else return _else; } @@ -530,21 +530,18 @@ Token::Value Scanner::scanNumber(bool _periodSeen) KEYWORD("bool", Token::BOOL) \ KEYWORD_GROUP('c') \ KEYWORD("case", Token::CASE) \ - KEYWORD("catch", Token::CATCH) \ KEYWORD("const", Token::CONST) \ KEYWORD("continue", Token::CONTINUE) \ KEYWORD("contract", Token::CONTRACT) \ KEYWORD_GROUP('d') \ - KEYWORD("debugger", Token::DEBUGGER) \ KEYWORD("default", Token::DEFAULT) \ KEYWORD("delete", Token::DELETE) \ KEYWORD("do", Token::DO) \ KEYWORD_GROUP('e') \ KEYWORD("else", Token::ELSE) \ - KEYWORD("enum", Token::FUTURE_RESERVED_WORD) \ + KEYWORD("extends", Token::EXTENDS) \ KEYWORD_GROUP('f') \ KEYWORD("false", Token::FALSE_LITERAL) \ - KEYWORD("finally", Token::FINALLY) \ KEYWORD("for", Token::FOR) \ KEYWORD("function", Token::FUNCTION) \ KEYWORD_GROUP('h') \ @@ -555,15 +552,12 @@ Token::Value Scanner::scanNumber(bool _periodSeen) KEYWORD("hash256", Token::HASH256) \ KEYWORD_GROUP('i') \ KEYWORD("if", Token::IF) \ - KEYWORD("implements", Token::FUTURE_STRICT_RESERVED_WORD) \ KEYWORD("in", Token::IN) \ - KEYWORD("instanceof", Token::INSTANCEOF) \ KEYWORD("int", Token::INT) \ KEYWORD("int32", Token::INT32) \ KEYWORD("int64", Token::INT64) \ KEYWORD("int128", Token::INT128) \ KEYWORD("int256", Token::INT256) \ - KEYWORD("interface", Token::FUTURE_STRICT_RESERVED_WORD) \ KEYWORD_GROUP('l') \ KEYWORD_GROUP('m') \ KEYWORD("mapping", Token::MAPPING) \ @@ -571,9 +565,7 @@ Token::Value Scanner::scanNumber(bool _periodSeen) KEYWORD("new", Token::NEW) \ KEYWORD("null", Token::NULL_LITERAL) \ KEYWORD_GROUP('p') \ - KEYWORD("package", Token::FUTURE_STRICT_RESERVED_WORD) \ KEYWORD("private", Token::PRIVATE) \ - KEYWORD("protected", Token::FUTURE_STRICT_RESERVED_WORD) \ KEYWORD("public", Token::PUBLIC) \ KEYWORD_GROUP('r') \ KEYWORD("real", Token::REAL) \ @@ -586,10 +578,7 @@ Token::Value Scanner::scanNumber(bool _periodSeen) KEYWORD_GROUP('t') \ KEYWORD("text", Token::TEXT) \ KEYWORD("this", Token::THIS) \ - KEYWORD("throw", Token::THROW) \ KEYWORD("true", Token::TRUE_LITERAL) \ - KEYWORD("try", Token::TRY) \ - KEYWORD("typeof", Token::TYPEOF) \ KEYWORD_GROUP('u') \ KEYWORD("uint", Token::UINT) \ KEYWORD("uint32", Token::UINT32) \ @@ -599,10 +588,8 @@ Token::Value Scanner::scanNumber(bool _periodSeen) KEYWORD("ureal", Token::UREAL) \ KEYWORD_GROUP('v') \ KEYWORD("var", Token::VAR) \ - KEYWORD("void", Token::VOID) \ KEYWORD_GROUP('w') \ KEYWORD("while", Token::WHILE) \ - KEYWORD("with", Token::WITH) static Token::Value KeywordOrIdentifierToken(const std::string& input) @@ -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); } |