long long int parse_int(const std::string &s) { const char *start = s.c_str(); const size_t len = strlen(start); const auto base = int_base(s, &start); size_t pos = 0; auto val = std::stoll(start, &pos, base); if (pos != len) throw std::runtime_error("invalid integer"); return val; }
IntLiteral (Token _token, std::string _value) : Expression(_token, nullptr, Kind::IntLit, nullptr) { // TODO: parse prefix, suffix, set value and type toupper(_value); bool positive = num_is_positive(_value); int base = int_base(_value); type = std::unique_ptr<Type>(new BaseType(_token, int_type(_value))); value = int_value(base, _value); if (!positive) { value = -value; } }