From: simonmar Date: Thu, 5 Sep 2002 10:25:01 +0000 (+0000) Subject: [project @ 2002-09-05 10:25:01 by simonmar] X-Git-Tag: Approx_11550_changesets_converted~1719 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=5ac854ef908d3f93164bad991b18944fc3a9db35;p=ghc-hetmet.git [project @ 2002-09-05 10:25:01 by simonmar] In code style, print negative floating point literals in parentheses to avoid interacting with surrounding syntax. Fixes SourceForge bug #604849 MERGE TO STABLE --- diff --git a/ghc/compiler/basicTypes/Literal.lhs b/ghc/compiler/basicTypes/Literal.lhs index 45a3dc5..773ff74 100644 --- a/ghc/compiler/basicTypes/Literal.lhs +++ b/ghc/compiler/basicTypes/Literal.lhs @@ -392,10 +392,11 @@ pprLit lit MachWord64 w | code_style -> pprHexVal w | otherwise -> ptext SLIT("__word64") <+> integer w - MachFloat f | code_style -> ptext SLIT("(StgFloat)") <> rational f + MachFloat f | code_style -> ptext SLIT("(StgFloat)") <> code_rational f | otherwise -> ptext SLIT("__float") <+> rational f - MachDouble d -> rational d + MachDouble d | code_style -> code_rational d + | otherwise -> rational d MachAddr p | code_style -> ptext SLIT("(void*)") <> integer p | otherwise -> ptext SLIT("__addr") <+> integer p @@ -408,6 +409,11 @@ pprLit lit pprHsString s, pprParendType ty]) +-- negative floating literals in code style need parentheses to avoid +-- interacting with surrounding syntax. +code_rational d | d < 0 = parens (rational d) + | otherwise = rational d + pprIntVal :: Integer -> SDoc -- Print negative integers with parens to be sure it's unambiguous pprIntVal i | i < 0 = parens (integer i)