diff options
| author | krangelov <kr.angelov@gmail.com> | 2019-09-20 10:37:50 +0200 |
|---|---|---|
| committer | krangelov <kr.angelov@gmail.com> | 2019-09-20 10:37:50 +0200 |
| commit | 4d79aa8b198f411d0ab6d66d76d9f77dfd3f922f (patch) | |
| tree | 0f72e72c6f5ccf57111b22cdb736b3290c86d1dd /src/compiler/GF/Grammar | |
| parent | 9d3badd8b225378269814e79395ae48beb83fa4d (diff) | |
remove obsolete code
Diffstat (limited to 'src/compiler/GF/Grammar')
| -rw-r--r-- | src/compiler/GF/Grammar/Lookup.hs | 10 | ||||
| -rw-r--r-- | src/compiler/GF/Grammar/Macros.hs | 11 | ||||
| -rw-r--r-- | src/compiler/GF/Grammar/Parser.y | 3 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/compiler/GF/Grammar/Lookup.hs b/src/compiler/GF/Grammar/Lookup.hs index 9435d1ec4..68c0191ae 100644 --- a/src/compiler/GF/Grammar/Lookup.hs +++ b/src/compiler/GF/Grammar/Lookup.hs @@ -51,11 +51,11 @@ lock c = lockRecType c -- return unlock c = unlockRecord c -- return -- to look up a constant etc in a search tree --- why here? AR 29/5/2008 -lookupIdent :: ErrorMonad m => Ident -> BinTree Ident b -> m b +lookupIdent :: ErrorMonad m => Ident -> Map.Map Ident b -> m b lookupIdent c t = - case lookupTree showIdent c t of - Ok v -> return v - Bad _ -> raise ("unknown identifier" +++ showIdent c) + case Map.lookup c t of + Just v -> return v + Nothing -> raise ("unknown identifier" +++ showIdent c) lookupIdentInfo :: ErrorMonad m => SourceModInfo -> Ident -> m Info lookupIdentInfo mo i = lookupIdent i (jments mo) @@ -148,7 +148,7 @@ lookupOrigInfo gr (m,c) = do allOrigInfos :: Grammar -> ModuleName -> [(QIdent,Info)] allOrigInfos gr m = fromErr [] $ do mo <- lookupModule gr m - return [((m,c),i) | (c,_) <- tree2list (jments mo), Ok (m,i) <- [lookupOrigInfo gr (m,c)]] + return [((m,c),i) | (c,_) <- Map.toList (jments mo), Ok (m,i) <- [lookupOrigInfo gr (m,c)]] lookupParamValues :: ErrorMonad m => Grammar -> QIdent -> m [Term] lookupParamValues gr c = do diff --git a/src/compiler/GF/Grammar/Macros.hs b/src/compiler/GF/Grammar/Macros.hs index 00b5dbb20..ab2e53473 100644 --- a/src/compiler/GF/Grammar/Macros.hs +++ b/src/compiler/GF/Grammar/Macros.hs @@ -22,14 +22,13 @@ import GF.Data.Operations import GF.Data.Str import GF.Infra.Ident import GF.Grammar.Grammar ---import GF.Grammar.Values import GF.Grammar.Predef import GF.Grammar.Printer import Control.Monad.Identity(Identity(..)) import qualified Data.Traversable as T(mapM) +import qualified Data.Map as Map import Control.Monad (liftM, liftM2, liftM3) ---import Data.Char (isDigit) import Data.List (sortBy,nub) import Data.Monoid import GF.Text.Pretty(render,(<+>),hsep,fsep) @@ -608,9 +607,9 @@ sortRec = sortBy ordLabel where -- | dependency check, detecting circularities and returning topo-sorted list -allDependencies :: (ModuleName -> Bool) -> BinTree Ident Info -> [(Ident,[Ident])] +allDependencies :: (ModuleName -> Bool) -> Map.Map Ident Info -> [(Ident,[Ident])] allDependencies ism b = - [(f, nub (concatMap opty (pts i))) | (f,i) <- tree2list b] + [(f, nub (concatMap opty (pts i))) | (f,i) <- Map.toList b] where opersIn t = case t of Q (n,c) | ism n -> [c] @@ -634,7 +633,7 @@ topoSortJments (m,mi) = do return (\cyc -> raise (render ("circular definitions:" <+> fsep (head cyc)))) (topoTest (allDependencies (==m) (jments mi))) - return (reverse [(i,info) | i <- is, Ok info <- [lookupTree showIdent i (jments mi)]]) + return (reverse [(i,info) | i <- is, Just info <- [Map.lookup i (jments mi)]]) topoSortJments2 :: ErrorMonad m => SourceModule -> m [[(Ident,Info)]] topoSortJments2 (m,mi) = do @@ -644,4 +643,4 @@ topoSortJments2 (m,mi) = do <+> fsep (head cyc)))) (topoTest2 (allDependencies (==m) (jments mi))) return - [[(i,info) | i<-is,Ok info<-[lookupTree showIdent i (jments mi)]] | is<-iss] + [[(i,info) | i<-is,Just info<-[Map.lookup i (jments mi)]] | is<-iss] diff --git a/src/compiler/GF/Grammar/Parser.y b/src/compiler/GF/Grammar/Parser.y index 9377bd7d5..da96f9265 100644 --- a/src/compiler/GF/Grammar/Parser.y +++ b/src/compiler/GF/Grammar/Parser.y @@ -24,6 +24,7 @@ import GF.Grammar.Lexer import GF.Compile.Update (buildAnyTree) import Data.List(intersperse) import Data.Char(isAlphaNum) +import qualified Data.Map as Map import PGF(mkCId) } @@ -139,7 +140,7 @@ ModHeader : ComplMod ModType '=' ModHeaderBody { let { mstat = $1 ; (mtype,id) = $2 ; (extends,with,opens) = $4 } - in (id, ModInfo mtype mstat noOptions extends with opens [] "" Nothing emptyBinTree) } + in (id, ModInfo mtype mstat noOptions extends with opens [] "" Nothing Map.empty) } ComplMod :: { ModuleStatus } ComplMod |
