From df26b134fc13cee4c854afd4306d847873885270 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Tue, 3 Sep 2013 07:51:25 +0000 Subject: fix in the GF compiler and runtime which let us to define pre construct detecting whether this is the last token. --- src/runtime/haskell/PGF/Macros.hs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/runtime/haskell/PGF/Macros.hs') diff --git a/src/runtime/haskell/PGF/Macros.hs b/src/runtime/haskell/PGF/Macros.hs index 31f7655b3..bfce7dd49 100644 --- a/src/runtime/haskell/PGF/Macros.hs +++ b/src/runtime/haskell/PGF/Macros.hs @@ -177,19 +177,24 @@ lengthBracketedString :: BracketedString -> Int lengthBracketedString (Leaf _) = 1 lengthBracketedString (Bracket _ _ _ _ _ bss) = sum (map lengthBracketedString bss) -untokn :: String -> BracketedTokn -> (String,[BracketedString]) -untokn nw (LeafKS ts) = (head ts,map Leaf ts) +untokn :: Maybe String -> BracketedTokn -> (Maybe String,[BracketedString]) +untokn nw (LeafKS ts) = (has_tok nw (head ts),map Leaf ts) untokn nw (LeafKP d vs) = let ts = sel d vs nw - in (head ts,map Leaf ts) + in (has_tok nw (head ts),map Leaf ts) where - sel d vs nw = - case [v | Alt v cs <- vs, any (\c -> isPrefixOf c nw) cs] of + sel d vs Nothing = d + sel d vs (Just w) = + case [v | Alt v cs <- vs, any (\c -> isPrefixOf c w) cs] of v:_ -> v _ -> d untokn nw (Bracket_ cat fid index fun es bss) = let (nw',bss') = mapAccumR untokn nw bss in (nw',[Bracket cat fid index fun es (concat bss')]) +has_tok nw t + | null t = nw + | otherwise = Just t + type CncType = (CId, FId) -- concrete type is the abstract type (the category) + the forest id mkLinTable :: Concr -> (CncType -> Bool) -> [CId] -> FunId -> [(CncType,CId,[Expr],LinTable)] -> LinTable -- cgit v1.2.3