diff --git a/src/compiler/GF/Compile/GrammarToLPGF.hs b/src/compiler/GF/Compile/GrammarToLPGF.hs index 669aec39e..a9e1209cb 100644 --- a/src/compiler/GF/Compile/GrammarToLPGF.hs +++ b/src/compiler/GF/Compile/GrammarToLPGF.hs @@ -59,7 +59,7 @@ mkCanon2lpgf opts gr am = do C.LiteralValue ll -> case ll of C.FloatConstant f -> return $ L.LFToken (show f) - C.IntConstant i -> return $ L.LFToken (show i) -- LFInt i ? + C.IntConstant i -> return $ L.LFToken (show i) C.StrConstant s -> return $ L.LFToken s C.ErrorValue err -> return $ L.LFError err diff --git a/src/runtime/haskell/LPGF.hs b/src/runtime/haskell/LPGF.hs index f13d94143..83d4f8514 100644 --- a/src/runtime/haskell/LPGF.hs +++ b/src/runtime/haskell/LPGF.hs @@ -21,8 +21,6 @@ data LPGF = LPGF { -- | Abstract syntax data Abstr = Abstr { - -- cats :: Map.Map CId (), - -- funs :: Map.Map CId Type } deriving (Show) -- | Concrete syntax @@ -35,12 +33,12 @@ data Concr = Concr { -- data Type = Type [CId] CId -- deriving (Show) --- | Linearisation type -data LinType = - LTStr - | LTInt Int - | LTProduct [LinType] - deriving (Show) +-- -- | Linearisation type +-- data LinType = +-- LTStr +-- | LTInt Int +-- | LTProduct [LinType] +-- deriving (Show) -- | Linearisation function data LinFun = @@ -50,7 +48,7 @@ data LinFun = | LFConcat LinFun LinFun | LFInt Int | LFTuple [LinFun] - | LFProjection LinFun LinFun -- ^ In order for the projection to be well-formed, t1 must be a tuple and t2 an integer within the bounds of the size of the tuple + | LFProjection LinFun LinFun | LFArgument Int deriving (Show, Read) @@ -94,12 +92,6 @@ encodeFile = Data.Binary.encodeFile readLPGF :: FilePath -> IO LPGF readLPGF = Data.Binary.decodeFile --- | Helper for building concat trees -mkConcat :: [LinFun] -> LinFun -mkConcat [] = LFEmpty -mkConcat [x] = x -mkConcat xs = foldl1 LFConcat xs - -- | Main linearize function linearize :: LPGF -> Language -> Expr -> String linearize lpgf lang = @@ -108,7 +100,6 @@ linearize lpgf lang = Nothing -> error $ printf "Unknown language: %s" (showCId lang) -- | Language-specific linearize function --- Section 2.5 linearizeConcr :: Concr -> Expr -> String linearizeConcr concr expr = lin2string $ lin (expr2tree expr) where diff --git a/testsuite/lpgf/Walking.hs b/testsuite/lpgf/Walking.hs index a6b312c7a..d8b1da0e9 100644 --- a/testsuite/lpgf/Walking.hs +++ b/testsuite/lpgf/Walking.hs @@ -70,3 +70,9 @@ walking = LPGF { }) ] } + +-- | Helper for building concat trees +mkConcat :: [LinFun] -> LinFun +mkConcat [] = LFEmpty +mkConcat [x] = x +mkConcat xs = foldl1 LFConcat xs