diff options
| author | hallgren <hallgren@chalmers.se> | 2013-09-19 20:48:10 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2013-09-19 20:48:10 +0000 |
| commit | 021b5f06d3900fe2b10d5d3ccf6ac286a779ef16 (patch) | |
| tree | cff0a0ca9c945dcef34f58a6e09fc5042c7abd65 /src/compiler/GF/Grammar/MMacros.hs | |
| parent | 3d5b9bd1fd46a51651cbfbd45f03e5b878aebbac (diff) | |
Introduce type RawIdent; only 9 imports of Data.ByteString.Char8 remain
The fact that identifiers are represented as ByteStrings is now an internal
implentation detail in module GF.Infra.Ident. Conversion between ByteString
and identifiers is only needed in the lexer and the Binary instances.
Diffstat (limited to 'src/compiler/GF/Grammar/MMacros.hs')
| -rw-r--r-- | src/compiler/GF/Grammar/MMacros.hs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/compiler/GF/Grammar/MMacros.hs b/src/compiler/GF/Grammar/MMacros.hs index f1d2f172a..1b9060003 100644 --- a/src/compiler/GF/Grammar/MMacros.hs +++ b/src/compiler/GF/Grammar/MMacros.hs @@ -26,7 +26,6 @@ import GF.Grammar.Values import GF.Grammar.Macros import Control.Monad -import qualified Data.ByteString.Char8 as BS import Text.PrettyPrint {- @@ -238,11 +237,11 @@ qualifTerm m = qualif [] where Cn c -> Q (m,c) Con c -> QC (m,c) _ -> composSafeOp (qualif xs) t - chV x = string2var $ ident2bs x + chV x = string2var $ ident2raw x -string2var :: BS.ByteString -> Ident -string2var s = case BS.unpack s of - c:'_':i -> identV (BS.singleton c) (readIntArg i) --- +string2var :: RawIdent -> Ident +string2var s = case showRawIdent s of + c:'_':i -> identV (rawIdentS [c]) (readIntArg i) --- _ -> identC s -- | reindex variables so that they tell nesting depth level @@ -254,7 +253,7 @@ reindexTerm = qualif (0,[]) where Vr x -> Vr $ look x g _ -> composSafeOp (qualif dg) t look x = maybe x id . lookup x --- if x is not in scope it is unchanged - ind x d = identC $ ident2bs x `BS.append` BS.singleton '_' `BS.append` BS.pack (show d) + ind x d = identC $ ident2raw x `prefixRawIdent` rawIdentS "_" `prefixRawIdent` rawIdentS (show d) {- -- this method works for context-free abstract syntax |
