summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Infra/Location.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2015-09-28 22:23:56 +0000
committerhallgren <hallgren@chalmers.se>2015-09-28 22:23:56 +0000
commit35be1828241bb8dacdf326810af388b7b349e591 (patch)
tree78ff946a0726e39c7eb5d871d903b9bdcd06520a /src/compiler/GF/Infra/Location.hs
parent82f238fe2b418a715fef52abc7136551fa535aac (diff)
Preliminary new shell feature: cc -trace.
You can now do things like cc -trace mkV "debug" to see a trace of all opers with their arguments and results during the computation of mkV "debug".
Diffstat (limited to 'src/compiler/GF/Infra/Location.hs')
-rw-r--r--src/compiler/GF/Infra/Location.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/compiler/GF/Infra/Location.hs b/src/compiler/GF/Infra/Location.hs
index 36bfab044..0bf85b37f 100644
--- a/src/compiler/GF/Infra/Location.hs
+++ b/src/compiler/GF/Infra/Location.hs
@@ -25,10 +25,16 @@ noLoc = L NoLoc
ppLocation :: FilePath -> Location -> Doc
ppLocation fpath NoLoc = pp fpath
ppLocation fpath (External p l) = ppLocation p l
-ppLocation fpath (Local b e)
- | b == e = fpath <> ":" <> b
- | otherwise = fpath <> ":" <> b <> "-" <> e
+ppLocation fpath (Local b e) =
+ opt (fpath/="") (fpath <> ":") <> b <> opt (b/=e) ("-" <> e)
+ where
+ opt False x = empty
+ opt True x = x
+ppL (L loc x) msg = hang (loc<>":") 4 ("In"<+>x<>":"<+>msg)
+
+
+instance Pretty Location where pp = ppLocation ""
+
+instance Pretty a => Pretty (L a) where pp (L loc x) = loc<>":"<>x
-ppL (L loc x) msg = hang (ppLocation "" loc<>":") 4
- ("In"<+>x<>":"<+>msg)