patrickt / pony

A source-to-source transformer for C99, written in Haskell.
Other
5 stars 0 forks source link

Base and size of constants are lost during transformation #51

Open cbarrett opened 13 years ago

cbarrett commented 13 years ago

Given:

int i = 0x10;

Pony outputs:

int i = 16;

Seems suboptimal especially when specifying constants in hex (or octal?) for readability purposes.

One possible approach -- implement Num etc on a type that stores the base information inside it and then format it accordingly during pretty printing. I don't think losing 0X10 to 0x10 is that big a deal at that point.

patrickt commented 13 years ago

This sort of thing would be useful, but the parsing code is already pretty hairy. Can we get it concise? I would go about it by defining data Base = Decimal | Octal | Hex and adding a Base subexpression to the CInteger type.