diff options
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/haskell/PGF/Forest.hs | 2 | ||||
| -rw-r--r-- | src/runtime/haskell/PGF/Macros.hs | 5 |
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 |
