mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 00:52:51 -06:00
Minor cleanup
This commit is contained in:
@@ -59,7 +59,7 @@ mkCanon2lpgf opts gr am = do
|
|||||||
|
|
||||||
C.LiteralValue ll -> case ll of
|
C.LiteralValue ll -> case ll of
|
||||||
C.FloatConstant f -> return $ L.LFToken (show f)
|
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.StrConstant s -> return $ L.LFToken s
|
||||||
|
|
||||||
C.ErrorValue err -> return $ L.LFError err
|
C.ErrorValue err -> return $ L.LFError err
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ data LPGF = LPGF {
|
|||||||
|
|
||||||
-- | Abstract syntax
|
-- | Abstract syntax
|
||||||
data Abstr = Abstr {
|
data Abstr = Abstr {
|
||||||
-- cats :: Map.Map CId (),
|
|
||||||
-- funs :: Map.Map CId Type
|
|
||||||
} deriving (Show)
|
} deriving (Show)
|
||||||
|
|
||||||
-- | Concrete syntax
|
-- | Concrete syntax
|
||||||
@@ -35,12 +33,12 @@ data Concr = Concr {
|
|||||||
-- data Type = Type [CId] CId
|
-- data Type = Type [CId] CId
|
||||||
-- deriving (Show)
|
-- deriving (Show)
|
||||||
|
|
||||||
-- | Linearisation type
|
-- -- | Linearisation type
|
||||||
data LinType =
|
-- data LinType =
|
||||||
LTStr
|
-- LTStr
|
||||||
| LTInt Int
|
-- | LTInt Int
|
||||||
| LTProduct [LinType]
|
-- | LTProduct [LinType]
|
||||||
deriving (Show)
|
-- deriving (Show)
|
||||||
|
|
||||||
-- | Linearisation function
|
-- | Linearisation function
|
||||||
data LinFun =
|
data LinFun =
|
||||||
@@ -50,7 +48,7 @@ data LinFun =
|
|||||||
| LFConcat LinFun LinFun
|
| LFConcat LinFun LinFun
|
||||||
| LFInt Int
|
| LFInt Int
|
||||||
| LFTuple [LinFun]
|
| 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
|
| LFArgument Int
|
||||||
deriving (Show, Read)
|
deriving (Show, Read)
|
||||||
|
|
||||||
@@ -94,12 +92,6 @@ encodeFile = Data.Binary.encodeFile
|
|||||||
readLPGF :: FilePath -> IO LPGF
|
readLPGF :: FilePath -> IO LPGF
|
||||||
readLPGF = Data.Binary.decodeFile
|
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
|
-- | Main linearize function
|
||||||
linearize :: LPGF -> Language -> Expr -> String
|
linearize :: LPGF -> Language -> Expr -> String
|
||||||
linearize lpgf lang =
|
linearize lpgf lang =
|
||||||
@@ -108,7 +100,6 @@ linearize lpgf lang =
|
|||||||
Nothing -> error $ printf "Unknown language: %s" (showCId lang)
|
Nothing -> error $ printf "Unknown language: %s" (showCId lang)
|
||||||
|
|
||||||
-- | Language-specific linearize function
|
-- | Language-specific linearize function
|
||||||
-- Section 2.5
|
|
||||||
linearizeConcr :: Concr -> Expr -> String
|
linearizeConcr :: Concr -> Expr -> String
|
||||||
linearizeConcr concr expr = lin2string $ lin (expr2tree expr)
|
linearizeConcr concr expr = lin2string $ lin (expr2tree expr)
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -70,3 +70,9 @@ walking = LPGF {
|
|||||||
})
|
})
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- | Helper for building concat trees
|
||||||
|
mkConcat :: [LinFun] -> LinFun
|
||||||
|
mkConcat [] = LFEmpty
|
||||||
|
mkConcat [x] = x
|
||||||
|
mkConcat xs = foldl1 LFConcat xs
|
||||||
|
|||||||
Reference in New Issue
Block a user