summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/GF/Grammar/CF.hs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/compiler/GF/Grammar/CF.hs b/src/compiler/GF/Grammar/CF.hs
index 123d843bf..fe76d7af8 100644
--- a/src/compiler/GF/Grammar/CF.hs
+++ b/src/compiler/GF/Grammar/CF.hs
@@ -23,12 +23,13 @@ import GF.Infra.UseIO
import GF.Data.Operations
import GF.Data.Utilities (nub')
+import qualified Data.Set as S
import Data.Char
import Data.List
--import System.FilePath
getCF :: FilePath -> String -> Err SourceGrammar
-getCF fpath = fmap (cf2gf fpath) . pCF
+getCF fpath = fmap (cf2gf fpath . uniqueFuns) . pCF
---------------------
-- the parser -------
@@ -77,6 +78,21 @@ type CFItem = Either CFCat String
type CFCat = String
type CFFun = String
+
+--------------------------------
+-- make function names unique --
+--------------------------------
+
+uniqueFuns :: CF -> CF
+uniqueFuns = snd . mapAccumL uniqueFun S.empty
+ where
+ uniqueFun funs (L l (fun,rule)) = (S.insert fun' funs,L l (fun',rule))
+ where
+ fun' = head [fun'|suffix<-"":map show ([2..]::[Int]),
+ let fun'=fun++suffix,
+ not (fun' `S.member` funs)]
+
+
--------------------------
-- the compiler ----------
--------------------------