1
0
forked from GitHub/gf-core

added function lengthBracketedString

This commit is contained in:
krasimir
2010-05-19 12:40:07 +00:00
parent 529447f56f
commit 8e01bc3118
2 changed files with 6 additions and 1 deletions

View File

@@ -12,7 +12,7 @@
-------------------------------------------------
module PGF.Forest( Forest(..)
, BracketedString, showBracketedString
, BracketedString, showBracketedString, lengthBracketedString
, linearizeWithBrackets
) where

View File

@@ -240,6 +240,11 @@ showBracketedString = render . ppBracketedString
ppBracketedString (Leaf t) = text t
ppBracketedString (Bracket cat fcat index bss) = parens (ppCId cat <+> hsep (map ppBracketedString bss))
-- | The length of the bracketed string in number of tokens.
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 nw (LeafKP d vs) = let ts = sel d vs nw