diff options
Diffstat (limited to 'libsolidity/parsing/Token.h')
-rw-r--r-- | libsolidity/parsing/Token.h | 132 |
1 files changed, 32 insertions, 100 deletions
diff --git a/libsolidity/parsing/Token.h b/libsolidity/parsing/Token.h index 88e77345..5f8141ae 100644 --- a/libsolidity/parsing/Token.h +++ b/libsolidity/parsing/Token.h @@ -187,113 +187,21 @@ namespace solidity K(SubWeek, "weeks", 0) \ K(SubYear, "years", 0) \ K(After, "after", 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 */\ + /* type keywords*/ \ K(Int, "int", 0) \ - K(Int8, "int8", 0) \ - K(Int16, "int16", 0) \ - K(Int24, "int24", 0) \ - K(Int32, "int32", 0) \ - K(Int40, "int40", 0) \ - K(Int48, "int48", 0) \ - K(Int56, "int56", 0) \ - K(Int64, "int64", 0) \ - K(Int72, "int72", 0) \ - K(Int80, "int80", 0) \ - K(Int88, "int88", 0) \ - K(Int96, "int96", 0) \ - K(Int104, "int104", 0) \ - K(Int112, "int112", 0) \ - K(Int120, "int120", 0) \ - K(Int128, "int128", 0) \ - K(Int136, "int136", 0) \ - K(Int144, "int144", 0) \ - K(Int152, "int152", 0) \ - K(Int160, "int160", 0) \ - K(Int168, "int168", 0) \ - K(Int176, "int176", 0) \ - K(Int184, "int184", 0) \ - K(Int192, "int192", 0) \ - K(Int200, "int200", 0) \ - K(Int208, "int208", 0) \ - K(Int216, "int216", 0) \ - K(Int224, "int224", 0) \ - K(Int232, "int232", 0) \ - K(Int240, "int240", 0) \ - K(Int248, "int248", 0) \ - K(Int256, "int256", 0) \ + K(IntM, "intM", 0) \ K(UInt, "uint", 0) \ - K(UInt8, "uint8", 0) \ - K(UInt16, "uint16", 0) \ - K(UInt24, "uint24", 0) \ - K(UInt32, "uint32", 0) \ - K(UInt40, "uint40", 0) \ - K(UInt48, "uint48", 0) \ - K(UInt56, "uint56", 0) \ - K(UInt64, "uint64", 0) \ - K(UInt72, "uint72", 0) \ - K(UInt80, "uint80", 0) \ - K(UInt88, "uint88", 0) \ - K(UInt96, "uint96", 0) \ - K(UInt104, "uint104", 0) \ - K(UInt112, "uint112", 0) \ - K(UInt120, "uint120", 0) \ - K(UInt128, "uint128", 0) \ - K(UInt136, "uint136", 0) \ - K(UInt144, "uint144", 0) \ - K(UInt152, "uint152", 0) \ - K(UInt160, "uint160", 0) \ - K(UInt168, "uint168", 0) \ - K(UInt176, "uint176", 0) \ - K(UInt184, "uint184", 0) \ - K(UInt192, "uint192", 0) \ - K(UInt200, "uint200", 0) \ - K(UInt208, "uint208", 0) \ - K(UInt216, "uint216", 0) \ - K(UInt224, "uint224", 0) \ - K(UInt232, "uint232", 0) \ - K(UInt240, "uint240", 0) \ - K(UInt248, "uint248", 0) \ - K(UInt256, "uint256", 0) \ - K(Bytes1, "bytes1", 0) \ - K(Bytes2, "bytes2", 0) \ - K(Bytes3, "bytes3", 0) \ - K(Bytes4, "bytes4", 0) \ - K(Bytes5, "bytes5", 0) \ - K(Bytes6, "bytes6", 0) \ - K(Bytes7, "bytes7", 0) \ - K(Bytes8, "bytes8", 0) \ - K(Bytes9, "bytes9", 0) \ - K(Bytes10, "bytes10", 0) \ - K(Bytes11, "bytes11", 0) \ - K(Bytes12, "bytes12", 0) \ - K(Bytes13, "bytes13", 0) \ - K(Bytes14, "bytes14", 0) \ - K(Bytes15, "bytes15", 0) \ - K(Bytes16, "bytes16", 0) \ - K(Bytes17, "bytes17", 0) \ - K(Bytes18, "bytes18", 0) \ - K(Bytes19, "bytes19", 0) \ - K(Bytes20, "bytes20", 0) \ - K(Bytes21, "bytes21", 0) \ - K(Bytes22, "bytes22", 0) \ - K(Bytes23, "bytes23", 0) \ - K(Bytes24, "bytes24", 0) \ - K(Bytes25, "bytes25", 0) \ - K(Bytes26, "bytes26", 0) \ - K(Bytes27, "bytes27", 0) \ - K(Bytes28, "bytes28", 0) \ - K(Bytes29, "bytes29", 0) \ - K(Bytes30, "bytes30", 0) \ - K(Bytes31, "bytes31", 0) \ - K(Bytes32, "bytes32", 0) \ + K(UIntM, "uintM", 0) \ K(Bytes, "bytes", 0) \ + K(BytesM, "bytesM", 0) \ K(Byte, "byte", 0) \ K(String, "string", 0) \ K(Address, "address", 0) \ K(Bool, "bool", 0) \ - K(Real, "real", 0) \ - K(UReal, "ureal", 0) \ + K(Fixed, "fixed", 0) \ + K(FixedMxN, "fixedMxN", 0) \ + K(UFixed, "ufixed", 0) \ + K(UFixedMxN, "ufixedMxN", 0) \ T(TypesEnd, NULL, 0) /* used as type enum end marker */ \ \ /* Literals */ \ @@ -403,5 +311,29 @@ private: static char const m_tokenType[NUM_TOKENS]; }; +class ElementaryTypeNameToken +{ +public: + ElementaryTypeNameToken(Token::Value token, std::string const& description) + { + solAssert(isElementaryTypeName(token, description), ""); + std::tie(m_name, M, N) = setTypes(token, description); + tok = token; + } + + std::string toString(bool const& tokValue = false) const& { return tokValue ? Token::toString(tok) : m_name; } + unsigned int const& returnM() const& { return M; } + unsigned int const& returnN() const& { return N; } + Token::Value const& returnTok() const& { return tok; } + static bool isElementaryTypeName(Token::Value _baseType, std::string const& _info); + +private: + Token::Value tok; + std::string m_name; + unsigned int M; + unsigned int N; + std::tuple<std::string, unsigned int, unsigned int> setTypes(Token::Value _baseType, std::string const& _toSet); +}; + } } |