summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Grammar/Grammar.hs
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2011-11-10 14:09:41 +0000
committerkr.angelov <kr.angelov@gmail.com>2011-11-10 14:09:41 +0000
commit416d231c5ecb4eea4bdb121e1503a74111373256 (patch)
tree6cd0501413c1ed7c738e029337571ca9cfed2eda /src/compiler/GF/Grammar/Grammar.hs
parent4baa44a933f9a7dd57db7eaab98048792e140e20 (diff)
Now PMCFG is compiled per module and at the end we only link it. The new compilation schema is few times faster.
Diffstat (limited to 'src/compiler/GF/Grammar/Grammar.hs')
-rw-r--r--src/compiler/GF/Grammar/Grammar.hs35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/compiler/GF/Grammar/Grammar.hs b/src/compiler/GF/Grammar/Grammar.hs
index acf2153bc..5174b1695 100644
--- a/src/compiler/GF/Grammar/Grammar.hs
+++ b/src/compiler/GF/Grammar/Grammar.hs
@@ -32,7 +32,9 @@ module GF.Grammar.Grammar (
abstractOfConcrete,
ModuleStatus(..),
-
+
+ PMCFG(..), Production(..), FId, FunId, SeqId, LIndex, Sequence,
+
Info(..),
Location(..), L(..), unLoc,
Type,
@@ -64,18 +66,25 @@ import GF.Infra.Option ---
import GF.Data.Operations
+import PGF.Data (FId, FunId, SeqId, LIndex, Sequence, BindType(..))
+
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.ByteString.Char8 as BS
import Text.PrettyPrint
import System.FilePath
+import Control.Monad.Identity
+
data SourceGrammar = MGrammar {
moduleMap :: Map.Map Ident SourceModInfo,
modules :: [(Ident,SourceModInfo)]
}
- deriving Show
data SourceModInfo = ModInfo {
mtype :: ModuleType,
@@ -86,9 +95,9 @@ data SourceModInfo = ModInfo {
mopens :: [OpenSpec],
mexdeps :: [Ident],
msrc :: FilePath,
+ mseqs :: Maybe (Array SeqId Sequence),
jments :: Map.Map Ident Info
}
- deriving Show
type SourceModule = (Ident, SourceModInfo)
@@ -116,9 +125,6 @@ isInherited c i = case c of
inheritAll :: Ident -> (Ident,MInclude)
inheritAll i = (i,MIAll)
-addOpenQualif :: Ident -> Ident -> SourceModInfo -> SourceModInfo
-addOpenQualif i j (ModInfo mt ms fs me mw ops med src js) = ModInfo mt ms fs me mw (OQualif i j : ops) med src js
-
data OpenSpec =
OSimple Ident
| OQualif Ident Ident
@@ -313,6 +319,14 @@ allConcreteModules gr =
[i | (i, m) <- modules gr, MTConcrete _ <- [mtype m], isCompleteModule m]
+data Production = Production {-# UNPACK #-} !FId
+ {-# UNPACK #-} !FunId
+ [[FId]]
+ deriving (Eq,Ord,Show)
+
+data PMCFG = PMCFG [Production]
+ (Array FunId (UArray LIndex SeqId))
+ deriving (Eq,Show)
-- | the constructors are judgements in
--
@@ -336,8 +350,8 @@ data Info =
| ResOverload [Ident] [(L Type,L Term)] -- ^ (/RES/) idents: modules inherited
-- judgements in concrete syntax
- | CncCat (Maybe (L Type)) (Maybe (L Term)) (Maybe (L Term)) -- ^ (/CNC/) lindef ini'zed,
- | CncFun (Maybe (Ident,Context,Type)) (Maybe (L Term)) (Maybe (L Term)) -- ^ (/CNC/) type info added at 'TC'
+ | CncCat (Maybe (L Type)) (Maybe (L Term)) (Maybe (L Term)) (Maybe PMCFG) -- ^ (/CNC/) lindef ini'zed,
+ | CncFun (Maybe (Ident,Context,Type)) (Maybe (L Term)) (Maybe (L Term)) (Maybe PMCFG) -- ^ (/CNC/) type info added at 'TC'
-- indirection to module Ident
| AnyInd Bool Ident -- ^ (/INDIR/) the 'Bool' says if canonical
@@ -364,11 +378,6 @@ type Fun = QIdent
type QIdent = (Ident,Ident)
-data BindType =
- Explicit
- | Implicit
- deriving (Eq,Ord,Show)
-
data Term =
Vr Ident -- ^ variable
| Cn Ident -- ^ constant