summaryrefslogtreecommitdiff
path: root/src/runtime/haskell
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2010-05-19 12:40:07 +0000
committerkrasimir <krasimir@chalmers.se>2010-05-19 12:40:07 +0000
commit1743e88192d3395221d8a023aee319182055191d (patch)
tree6bb9f74b60390a68c8f9d2739bd5a11bcbe697f5 /src/runtime/haskell
parent31856ebb4cf9aa181b2875c88e964cefae319c96 (diff)
added function lengthBracketedString
Diffstat (limited to 'src/runtime/haskell')
-rw-r--r--src/runtime/haskell/PGF/Forest.hs2
-rw-r--r--src/runtime/haskell/PGF/Macros.hs5
2 files changed, 6 insertions, 1 deletions
diff --git a/src/runtime/haskell/PGF/Forest.hs b/src/runtime/haskell/PGF/Forest.hs
index 4c59ce0d9..4cc3dd908 100644
--- a/src/runtime/haskell/PGF/Forest.hs
+++ b/src/runtime/haskell/PGF/Forest.hs
@@ -12,7 +12,7 @@
-------------------------------------------------
module PGF.Forest( Forest(..)
- , BracketedString, showBracketedString
+ , BracketedString, showBracketedString, lengthBracketedString
, linearizeWithBrackets
) where
diff --git a/src/runtime/haskell/PGF/Macros.hs b/src/runtime/haskell/PGF/Macros.hs
index 0670a0d20..f4bfae646 100644
--- a/src/runtime/haskell/PGF/Macros.hs
+++ b/src/runtime/haskell/PGF/Macros.hs
@@ -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