summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Grammar
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2013-11-05 13:11:10 +0000
committerhallgren <hallgren@chalmers.se>2013-11-05 13:11:10 +0000
commit3814841d7d3b77b3f033cb98c1c0a04ac39435d7 (patch)
tree1ad913a0a7ca870b7ec62db86afbc422cab97df1 /src/compiler/GF/Grammar
parent74357cdedf90178253d5d812931cb78a9bdf54aa (diff)
Eliminate mutual dependencies between the GF compiler and the PGF library
+ References to modules under src/compiler have been eliminated from the PGF library (under src/runtime/haskell). Only two functions had to be moved (from GF.Data.Utilities to PGF.Utilities) to make this possible, other apparent dependencies turned out to be vacuous. + In gf.cabal, the GF executable no longer directly depends on the PGF library source directory, but only on the exposed library modules. This means that there is less duplication in gf.cabal and that the 30 modules in the PGF library will no longer be compiled twice while building GF. To make this possible, additional PGF library modules have been exposed, even though they should probably be considered for internal use only. They could be collected in a PGF.Internal module, or marked as "unstable", to make this explicit. + Also, by using the -fwarn-unused-imports flag, ~220 redundant imports were found and removed, reducing the total number of imports by ~15%.
Diffstat (limited to 'src/compiler/GF/Grammar')
-rw-r--r--src/compiler/GF/Grammar/Analyse.hs4
-rw-r--r--src/compiler/GF/Grammar/Binary.hs8
-rw-r--r--src/compiler/GF/Grammar/CF.hs2
-rw-r--r--src/compiler/GF/Grammar/EBNF.hs2
-rw-r--r--src/compiler/GF/Grammar/Grammar.hs10
-rw-r--r--src/compiler/GF/Grammar/Lexer.hs4
-rw-r--r--src/compiler/GF/Grammar/Lookup.hs4
-rw-r--r--src/compiler/GF/Grammar/Macros.hs4
-rw-r--r--src/compiler/GF/Grammar/PatternMatch.hs4
-rw-r--r--src/compiler/GF/Grammar/Printer.hs8
-rw-r--r--src/compiler/GF/Grammar/Values.hs2
11 files changed, 27 insertions, 25 deletions
diff --git a/src/compiler/GF/Grammar/Analyse.hs b/src/compiler/GF/Grammar/Analyse.hs
index 0df678345..023b76ad3 100644
--- a/src/compiler/GF/Grammar/Analyse.hs
+++ b/src/compiler/GF/Grammar/Analyse.hs
@@ -10,7 +10,7 @@ module GF.Grammar.Analyse (
import GF.Grammar.Grammar
import GF.Infra.Ident
-import GF.Infra.Option ---
+--import GF.Infra.Option ---
import GF.Grammar.Macros
import GF.Grammar.Lookup
@@ -18,7 +18,7 @@ import GF.Data.Operations
import qualified Data.Map as Map
import Data.List (nub)
-import Debug.Trace
+--import Debug.Trace
stripSourceGrammar :: SourceGrammar -> SourceGrammar
stripSourceGrammar sgr = mGrammar [(i, m{jments = Map.map stripInfo (jments m)}) | (i,m) <- modules sgr]
diff --git a/src/compiler/GF/Grammar/Binary.hs b/src/compiler/GF/Grammar/Binary.hs
index ba12fde06..6641b5718 100644
--- a/src/compiler/GF/Grammar/Binary.hs
+++ b/src/compiler/GF/Grammar/Binary.hs
@@ -12,9 +12,9 @@ module GF.Grammar.Binary(decodeModule,decodeModuleHeader,encodeModule) where
import Prelude hiding (catch)
import Control.Exception(catch,ErrorCall(..),throwIO)
-import Data.Char
+--import Data.Char
import Data.Binary
-import Control.Monad
+--import Control.Monad
import qualified Data.Map as Map
import qualified Data.ByteString.Char8 as BS
@@ -23,7 +23,7 @@ import GF.Infra.Ident
import GF.Infra.Option
import GF.Grammar.Grammar
-import PGF.Binary
+import PGF() -- Binary instances
-- Please change this every time when the GFO format is changed
gfoVersion = "GF02"
@@ -346,3 +346,5 @@ decodeFile' fpath = addFPath fpath (decodeFile fpath)
addFPath fpath m = m `catch` handle
where
handle (ErrorCall msg) = throwIO (ErrorCall (fpath++": "++msg))
+
+decodingError = fail "This file was compiled with different version of GF"
diff --git a/src/compiler/GF/Grammar/CF.hs b/src/compiler/GF/Grammar/CF.hs
index 1daa9a1ea..123d843bf 100644
--- a/src/compiler/GF/Grammar/CF.hs
+++ b/src/compiler/GF/Grammar/CF.hs
@@ -25,7 +25,7 @@ import GF.Data.Utilities (nub')
import Data.Char
import Data.List
-import System.FilePath
+--import System.FilePath
getCF :: FilePath -> String -> Err SourceGrammar
getCF fpath = fmap (cf2gf fpath) . pCF
diff --git a/src/compiler/GF/Grammar/EBNF.hs b/src/compiler/GF/Grammar/EBNF.hs
index e5cbf6c7f..b1854da54 100644
--- a/src/compiler/GF/Grammar/EBNF.hs
+++ b/src/compiler/GF/Grammar/EBNF.hs
@@ -24,7 +24,7 @@ import GF.Grammar.Grammar
import Data.Char
import Data.List
-import System.FilePath
+--import System.FilePath
diff --git a/src/compiler/GF/Grammar/Grammar.hs b/src/compiler/GF/Grammar/Grammar.hs
index 61c07399c..8db78a0f0 100644
--- a/src/compiler/GF/Grammar/Grammar.hs
+++ b/src/compiler/GF/Grammar/Grammar.hs
@@ -68,15 +68,15 @@ import GF.Data.Operations
import PGF.Data (FId, FunId, SeqId, LIndex, Sequence, BindType(..))
-import Data.List
+--import Data.List
import Data.Array.IArray
import Data.Array.Unboxed
import qualified Data.Map as Map
-import qualified Data.Set as Set
-import qualified Data.IntMap as IntMap
+--import qualified Data.Set as Set
+--import qualified Data.IntMap as IntMap
import Text.PrettyPrint
-import System.FilePath
-import Control.Monad.Identity
+--import System.FilePath
+--import Control.Monad.Identity
diff --git a/src/compiler/GF/Grammar/Lexer.hs b/src/compiler/GF/Grammar/Lexer.hs
index 8e6b05250..dfa78df64 100644
--- a/src/compiler/GF/Grammar/Lexer.hs
+++ b/src/compiler/GF/Grammar/Lexer.hs
@@ -1,5 +1,5 @@
{-# LANGUAGE CPP,MagicHash,BangPatterns #-}
-{-# LINE 3 "lexer/Lexer.x" #-}
+-- {-# LINE 3 "lexer/Lexer.x" #-}
module GF.Grammar.Lexer
( Token(..), Posn(..)
@@ -8,7 +8,7 @@ module GF.Grammar.Lexer
) where
import GF.Infra.Ident
-import GF.Data.Operations
+--import GF.Data.Operations
import qualified Data.ByteString.Char8 as BS
import qualified Data.Map as Map
diff --git a/src/compiler/GF/Grammar/Lookup.hs b/src/compiler/GF/Grammar/Lookup.hs
index d85c7c48b..4076346a8 100644
--- a/src/compiler/GF/Grammar/Lookup.hs
+++ b/src/compiler/GF/Grammar/Lookup.hs
@@ -40,8 +40,8 @@ import GF.Grammar.Predef
import GF.Grammar.Lockfield
import Data.List (sortBy)
-import Data.Maybe (maybe)
-import Control.Monad
+--import Data.Maybe (maybe)
+--import Control.Monad
import Text.PrettyPrint
import qualified Data.Map as Map
diff --git a/src/compiler/GF/Grammar/Macros.hs b/src/compiler/GF/Grammar/Macros.hs
index f6d5c7572..db17b4451 100644
--- a/src/compiler/GF/Grammar/Macros.hs
+++ b/src/compiler/GF/Grammar/Macros.hs
@@ -22,14 +22,14 @@ import GF.Data.Operations
import GF.Data.Str
import GF.Infra.Ident
import GF.Grammar.Grammar
-import GF.Grammar.Values
+--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 Control.Monad (liftM, liftM2, liftM3)
-import Data.Char (isDigit)
+--import Data.Char (isDigit)
import Data.List (sortBy,nub)
import Text.PrettyPrint
diff --git a/src/compiler/GF/Grammar/PatternMatch.hs b/src/compiler/GF/Grammar/PatternMatch.hs
index bd92e3096..071deb709 100644
--- a/src/compiler/GF/Grammar/PatternMatch.hs
+++ b/src/compiler/GF/Grammar/PatternMatch.hs
@@ -24,10 +24,10 @@ import GF.Infra.Ident
import GF.Grammar.Macros
import GF.Grammar.Printer
-import Data.List
+--import Data.List
import Control.Monad
import Text.PrettyPrint
-import Debug.Trace
+--import Debug.Trace
matchPattern :: [(Patt,rhs)] -> Term -> Err (rhs, Substitution)
matchPattern pts term =
diff --git a/src/compiler/GF/Grammar/Printer.hs b/src/compiler/GF/Grammar/Printer.hs
index 5d8751736..dba08ce44 100644
--- a/src/compiler/GF/Grammar/Printer.hs
+++ b/src/compiler/GF/Grammar/Printer.hs
@@ -29,15 +29,15 @@ import GF.Infra.Option
import GF.Grammar.Values
import GF.Grammar.Grammar
-import PGF.Expr (ppMeta)
+import PGF.Data (ppMeta)
import PGF.Printer (ppFId, ppFunId, ppSeqId, ppSeq)
import Text.PrettyPrint
-import Data.Maybe (maybe, isNothing)
+import Data.Maybe (isNothing)
import Data.List (intersperse)
import qualified Data.Map as Map
-import qualified Data.IntMap as IntMap
-import qualified Data.Set as Set
+--import qualified Data.IntMap as IntMap
+--import qualified Data.Set as Set
import qualified Data.Array.IArray as Array
data TermPrintQual
diff --git a/src/compiler/GF/Grammar/Values.hs b/src/compiler/GF/Grammar/Values.hs
index 1a68ddc89..0476825df 100644
--- a/src/compiler/GF/Grammar/Values.hs
+++ b/src/compiler/GF/Grammar/Values.hs
@@ -24,7 +24,7 @@ module GF.Grammar.Values (-- * values used in TC type checking
--Z tree2exp, loc2treeFocus
) where
-import GF.Data.Operations
+--import GF.Data.Operations
---Z import GF.Data.Zipper
import GF.Infra.Ident