class HexLit """ r'HEX_LIT_UNSIGN 0x[\dA-Fa-f][\dA-Fa-f]*(u|_u)(8|16|32|64)?' r'HEX_LIT_EXPLICIT 0x[\dA-Fa-f][\dA-Fa-f]*_(8|16|32|64)?' r'HEX_LIT 0x[\dA-Fa-f][\dA-Fa-f]*' """ def literals """ r'HEX_LIT 0x[\dA-Fa-f][\dA-Fa-f]*', """ h = 0x1 assert h == 1 assert h.typeOf is Int32 h1 = 0xa assert h1 == 10 assert h1.typeOf is Int32 h2 = 0xF assert h2 == 15 assert h2.typeOf is Int32 h3 = 0x02 assert h3 == 2 assert h3.typeOf is Int32 h4 = 0x0A assert h4 == 10 assert h4.typeOf is Int32 h5 = 0x0F assert h5 == 15 assert h5.typeOf is Int32 h6 = 0x03 assert h6 == 3 assert h6.typeOf is Int32 h7 = 0x0fe assert h7 == 254 assert h.typeOf is Int32 h8 = 0x0FF assert h8 == 255 assert h8.typeOf is Int32 h9 = 0x0FFf assert h9 == 4095 assert h9.typeOf is Int32 def unsign """ r'HEX_LIT_UNSIGN 0x[\dA-Fa-f][\dA-Fa-f]*(u|_u)(8|16|32|64)?' """ h2a = 0xfu assert h2a == 15u assert h2a.typeOf is UInt32 h2b = 0xf_u assert h2b == 15u assert h2b.typeOf is UInt32 h1 = 0xffu assert h1 == 255u assert h1.typeOf is UInt32 h2 = 0xff_u assert h2 == 255u assert h2.typeOf is UInt32 h3 = 0xf0u16 assert h3 == 240u assert h3.typeOf is UInt16 h4 = 0xf0_u16 assert h4 == 240u assert h4.typeOf is UInt16 h5 = 0xFF_u64 assert h5 == 255u assert h5.typeOf is UInt64 h6 = 0xFF1_u64 assert h6 == 4081u assert h6.typeOf is UInt64 h7 = 0xFF_u8 assert h7 == 255u assert h7.typeOf is Byte h8 = 0xFFu8 assert h8 == 255u assert h8.typeOf is Byte def explicit """ r'HEX_LIT_EXPLICIT 0x[\dA-Fa-f][\dA-Fa-f]*_(8|16|32|64)? """ h1 = 0xe_8 assert h1 == 14u assert h1.typeOf is Byte h2 = 0xa_ assert h2 == 10u assert h2.typeOf is UInt32 h3 = 0xe_16 assert h3 == 14u assert h3.typeOf is UInt16 h4 = 0x1f_32 assert h4 == 31u assert h4.typeOf is UInt32 h5 = 0xFffF_64 assert h5 == 65535u assert h5.typeOf is UInt64 h6 = 0xFeed_16 assert h6 == 65261u assert h6.typeOf is UInt16 h7 = 0xffffffff_u32 assert h7 == 4294967295u assert h7.typeOf is UInt32 def miscellaneous b = 255u8 b = 255u8 & 31u8 assert b == 31_u8 assert b.typeOf is Byte assert b == 0x1fu8 b = 255u8 b &= 0x1fu8 assert b == 0x1F_u8 assert b.typeOf is Byte b = 255u8 b = b & 0x1fu8 assert b == 0x1fu8 b = 255u8 b = b & 31u8 assert b == 0x1fu8 b = 255u8 b1 = 0x1fu8 b = b & b1 assert b == 0x1fu8 c = 0x0_u8 c |= 0x1e_u8 assert c == 0x1e_u8 c = 0x0_u8 c = c | 0x1e_u8 assert c == 0x1e_u8 c = 0x0_u8 c1 = 0x1e_u8 c = c | c1 assert c == 0x1e_u8 def inferredTypes a = 0xfffffff assert a.typeOf is int32 b = 0xffffffff assert b.typeOf is uint32 c = 0xfffffffff assert c.typeOf is int64 d = 0xffffffffffffffff assert d.typeOf is uint64 def main .literals .unsign .explicit .miscellaneous .inferredTypes