diff options
author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2008-03-27 18:54:36 +0000 |
---|---|---|
committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2008-03-27 18:54:36 +0000 |
commit | 81e51a265d315609cb28e190fc59ca690f5f5d6e (patch) | |
tree | 0b5995c5a5edf11ce66a3bdf352bb04ea691fdd5 | |
parent | d74b100eaa9e782710b752805ac148e91e5c6850 (diff) | |
download | haskell-81e51a265d315609cb28e190fc59ca690f5f5d6e.tar.gz |
Change syntax for qualified names in External Core
Two changes that make the ext-core code uglier but the parser easier:
- Prefix qualified names with "^" so that we can more easily
distinguish a qualified name:
^a:Foo.Bar.quux
from an unqualified name:
a
- z-encode package names ("ghc-prim" was the culprit.)
-rw-r--r-- | compiler/coreSyn/MkExternalCore.lhs | 10 | ||||
-rw-r--r-- | compiler/coreSyn/PprExternalCore.lhs | 5 |
2 files changed, 11 insertions, 4 deletions
diff --git a/compiler/coreSyn/MkExternalCore.lhs b/compiler/coreSyn/MkExternalCore.lhs index 1dc3b7e929..244144c22d 100644 --- a/compiler/coreSyn/MkExternalCore.lhs +++ b/compiler/coreSyn/MkExternalCore.lhs @@ -25,6 +25,7 @@ import Name import NameSet import UniqSet import Outputable +import Encoding import ForeignCall import DynFlags import StaticFlags @@ -219,13 +220,16 @@ make_var_id = make_id True -- *do* want to keep the package name (we don't want baseZCGHCziBase, -- because that would just be ugly.) -- SIGH. +-- We encode the package name as well. make_mid :: Module -> C.Id -- Super ugly code, but I can't find anything else that does quite what I -- want (encodes the hierarchical module name without encoding the colon -- that separates the package name from it.) -make_mid m = (packageIdString (modulePackageId m)) ++ - ":" ++ - showSDoc (pprCode CStyle (pprModuleName (moduleName m))) +make_mid m = showSDoc $ + (text $ zEncodeString $ packageIdString $ modulePackageId m) + <> text ":" + <> (pprEncoded $ pprModuleName $ moduleName m) + where pprEncoded = pprCode CStyle make_qid :: Bool -> Name -> C.Qual C.Id make_qid is_var n = (mname,make_id is_var n) diff --git a/compiler/coreSyn/PprExternalCore.lhs b/compiler/coreSyn/PprExternalCore.lhs index 22449df323..c58144c29c 100644 --- a/compiler/coreSyn/PprExternalCore.lhs +++ b/compiler/coreSyn/PprExternalCore.lhs @@ -80,7 +80,10 @@ pname id = text (zEncodeString id) pqname :: Qual Id -> Doc pqname ("",id) = pname id -pqname (m,id) = text m <> char '.' <> pname id +-- We print out a special character before a qualified name so as to +-- disambiguate unqualified names like "m" from qualified names like +-- "m:Foo.Bar.y". This makes the ext-core parser easier. +pqname (m,id) = char '^' <> text m <> char '.' <> pname id ptbind, pattbind :: Tbind -> Doc ptbind (t,Klifted) = pname t |