Bump version of .gfo and .pgf files, improve error messages on version mismatch

Becacuse of the new special tokens added to the Symbol type, .gfo and .pgf
files produced with the current version of GF can not always be used with
older versions of GF and the PGF run-time system.

The PGF version number was increased from (2,0) to (2,1). GF can still
read version (2,0) and (1,0), so old PGF files continue to work.

The GFO version was increased from "GF03" to "GF04".
This commit is contained in:
hallgren
2015-06-23 12:58:14 +00:00
parent 984c09923c
commit 22ba8d34ff
4 changed files with 35 additions and 37 deletions

View File

@@ -15,7 +15,7 @@ import qualified Data.IntMap as IntMap
import Control.Monad
pgfMajorVersion, pgfMinorVersion :: Word16
version@(pgfMajorVersion, pgfMinorVersion) = (2,0)
version@(pgfMajorVersion, pgfMinorVersion) = (2,1)
instance Binary PGF where
put pgf = do putWord16be pgfMajorVersion
@@ -23,11 +23,14 @@ instance Binary PGF where
put (gflags pgf)
put (absname pgf, abstract pgf)
put (concretes pgf)
get = do v1 <- getWord16be
v2 <- getWord16be
case (v1,v2) of
v | v==version -> getPGF'
| v==Old.version -> Old.getPGF'
get = do major<- getWord16be
minor <- getWord16be
let v = (major,minor)
if major==pgfMajorVersion && minor<=pgfMinorVersion
then getPGF'
else if v==Old.version
then Old.getPGF'
else fail $ "Unsupported PGF version "++show (major,minor)
getPGF'=do gflags <- get
(absname,abstract) <- get