diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-09-03 07:51:25 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-09-03 07:51:25 +0000 |
| commit | df26b134fc13cee4c854afd4306d847873885270 (patch) | |
| tree | 3dd98c1e8b5286d60534b06f23d069676a743335 /src/runtime/haskell/PGF/Macros.hs | |
| parent | d626a194de5c48e0ceedfc3946443f63fd6a4ad8 (diff) | |
fix in the GF compiler and runtime which let us to define pre construct detecting whether this is the last token.
Diffstat (limited to 'src/runtime/haskell/PGF/Macros.hs')
| -rw-r--r-- | src/runtime/haskell/PGF/Macros.hs | 15 |
1 files changed, 10 insertions, 5 deletions
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 |
