On 13/11/2018 11:57, Michael Powell wrote:
Decimal values can be negative. Octal and hex values can't.
Right, I understand that. However, ultimately when the AST is synthesized, I do not care whether numeric literals were hex, octal, decimal, or some other indeterminate radix. The sign applies to whatever that result is, at least according to the language spec I am working with.
That's fine though -- as I said you can still just use intptr_t in the AST and it will store the signed two's complement equivalent of whatever literal was specified, regardless of radix. You just need to specify the signedness correctly in the actual parse step. I'm not sure exactly what was making it fail with intmax_t, but it's not entirely surprising, and using uintmax_t to parse makes it work as expected.