1
0
forked from GitHub/gf-core

Add backward compatibility for reading old PGF files

Some backwards incompatible changes were made to the PGF file format after
the release of GF 3.5. This patch adds a module for reading PGF files in the
old format.

This means that old PGF files on the grammaticalframework.org server will
continue to work after we install the latest version of GF.
This commit is contained in:
hallgren
2013-12-17 13:27:37 +00:00
parent 2b16962835
commit e0481e3b8a
4 changed files with 193 additions and 4 deletions

View File

@@ -1,8 +1,9 @@
module PGF.Binary where
module PGF.Binary(putSplitAbs) where
import PGF.CId
import PGF.Data
import PGF.Optimize
import qualified PGF.OldBinary as Old
import Data.Binary
import Data.Binary.Put
import Data.Binary.Get
@@ -14,7 +15,7 @@ import qualified Data.IntMap as IntMap
import Control.Monad
pgfMajorVersion, pgfMinorVersion :: Word16
(pgfMajorVersion, pgfMinorVersion) = (2,0)
version@(pgfMajorVersion, pgfMinorVersion) = (2,0)
instance Binary PGF where
put pgf = do putWord16be pgfMajorVersion
@@ -24,7 +25,11 @@ instance Binary PGF where
put (concretes pgf)
get = do v1 <- getWord16be
v2 <- getWord16be
gflags <- get
case (v1,v2) of
v | v==version -> getPGF'
| v==Old.version -> Old.getPGF'
getPGF'=do gflags <- get
(absname,abstract) <- get
concretes <- get
return $ updateProductionIndices $