summaryrefslogtreecommitdiff
path: root/src/GF/Speech/RegExp.hs
diff options
context:
space:
mode:
authorbjorn <bjorn@bringert.net>2008-09-26 09:20:39 +0000
committerbjorn <bjorn@bringert.net>2008-09-26 09:20:39 +0000
commit92c76a626571fd2ccc50641595cbfec9681656dc (patch)
tree6a28e240a0825df7ff57276ef303b15702a2dbb9 /src/GF/Speech/RegExp.hs
parent8fa99886b3a47cf58a2777ffb6d98220ee122643 (diff)
Added --output-format=ebnf.
Diffstat (limited to 'src/GF/Speech/RegExp.hs')
-rw-r--r--src/GF/Speech/RegExp.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/GF/Speech/RegExp.hs b/src/GF/Speech/RegExp.hs
index 5ee40828e..902569629 100644
--- a/src/GF/Speech/RegExp.hs
+++ b/src/GF/Speech/RegExp.hs
@@ -130,14 +130,14 @@ symbolsRE (RESymbol x) = [x]
-- Debugging
-prRE :: RE String -> String
+prRE :: (a -> String) -> RE a -> String
prRE = prRE' 0
-prRE' _ (REUnion []) = "<NULL>"
-prRE' n (REUnion xs) = p n 1 (concat (intersperse " | " (map (prRE' 1) xs)))
-prRE' n (REConcat xs) = p n 2 (unwords (map (prRE' 2) xs))
-prRE' n (RERepeat x) = p n 3 (prRE' 3 x) ++ "*"
-prRE' _ (RESymbol s) = s
+prRE' _ _ (REUnion []) = "<NULL>"
+prRE' n f (REUnion xs) = p n 1 (concat (intersperse " | " (map (prRE' 1 f) xs)))
+prRE' n f (REConcat xs) = p n 2 (unwords (map (prRE' 2 f) xs))
+prRE' n f (RERepeat x) = p n 3 (prRE' 3 f x) ++ "*"
+prRE' _ f (RESymbol s) = f s
p n m s | n >= m = "(" ++ s ++ ")"
| True = s