From e0481e3b8a8b6de306cff4c0645c6d19ae443e9a Mon Sep 17 00:00:00 2001 From: hallgren Date: Tue, 17 Dec 2013 13:27:37 +0000 Subject: 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. --- src/runtime/haskell/PGF/Binary.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/runtime/haskell/PGF/Binary.hs') diff --git a/src/runtime/haskell/PGF/Binary.hs b/src/runtime/haskell/PGF/Binary.hs index e2403809e..4d4c53102 100644 --- a/src/runtime/haskell/PGF/Binary.hs +++ b/src/runtime/haskell/PGF/Binary.hs @@ -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 $ -- cgit v1.2.3