12 Nov
2018
12 Nov
'18
10:43 p.m.
On 13/11/2018 05:27, Michael Powell wrote:
Oops, my mistake. An error in one of the rules. Fixed it, and can demonstrate that negative values do not seem to parse correctly:
Hex and octal literals produce unsigned values. You need to put those into a uintmax_t, not an intmax_t. FWIW, you can still use an intmax_t in your AST if you want, as the automatic attribute conversion will permit the twos-complement conversion (though it might annoy some sanitisers). hex_val %= no_case["0x"] >> uint_parser<std::uintmax_t, 16>{}; oct_val %= "0" >> uint_parser<std::uintmax_t, 8>{}; dec_val %= int_parser<ast::int_t, 10>{}; If you feel especially enthused, you can use std::make_unsigned_t<ast::int_t> instead.