Strip leading zeros from decimal literals
This commit is contained in:
parent
f0223ec40a
commit
6cdfb98086
|
@ -206,7 +206,7 @@ genLiteral l = missing $ "genLiteral " ++ show l
|
|||
|
||||
genLiteralRepr :: A.LiteralRepr -> CGen ()
|
||||
genLiteralRepr (A.RealLiteral m s) = tell [s]
|
||||
genLiteralRepr (A.IntLiteral m s) = tell [s]
|
||||
genLiteralRepr (A.IntLiteral m s) = genDecimal s
|
||||
genLiteralRepr (A.HexLiteral m s) = tell ["0x", s]
|
||||
genLiteralRepr (A.ByteLiteral m s) = tell ["'", convStringLiteral s, "'"]
|
||||
genLiteralRepr (A.StringLiteral m s) = tell ["\"", convStringLiteral s, "\""]
|
||||
|
@ -215,6 +215,14 @@ genLiteralRepr (A.ArrayLiteral m aes)
|
|||
genArrayLiteralElems aes
|
||||
tell ["}"]
|
||||
|
||||
-- | Generate a decimal literal -- removing leading zeroes to avoid producing
|
||||
-- an octal literal!
|
||||
genDecimal :: String -> CGen ()
|
||||
genDecimal "0" = tell ["0"]
|
||||
genDecimal ('0':s) = genDecimal s
|
||||
genDecimal ('-':s) = tell ["-"] >> genDecimal s
|
||||
genDecimal s = tell [s]
|
||||
|
||||
genArrayLiteralElems :: [A.ArrayElem] -> CGen ()
|
||||
genArrayLiteralElems aes
|
||||
= sequence_ $ intersperse genComma $ map genElem aes
|
||||
|
|
Loading…
Reference in New Issue
Block a user