diff options
| author | bjorn <bjorn@bringert.net> | 2008-09-26 12:57:20 +0000 |
|---|---|---|
| committer | bjorn <bjorn@bringert.net> | 2008-09-26 12:57:20 +0000 |
| commit | b0dde31f00a5bc4df496d15008e6c3d525925d3a (patch) | |
| tree | f53def4dce9622cc6bf3d4cc704ee8e6ca4c3b80 /src/GF/Speech/CFG.hs | |
| parent | 2f3b7d1c5560aabb19db149c2a8e333931884d30 (diff) | |
Added semantic interpretation tag printing to the *bnf grammar printers.
Diffstat (limited to 'src/GF/Speech/CFG.hs')
| -rw-r--r-- | src/GF/Speech/CFG.hs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/GF/Speech/CFG.hs b/src/GF/Speech/CFG.hs index 8e6c520d6..3e4db14d4 100644 --- a/src/GF/Speech/CFG.hs +++ b/src/GF/Speech/CFG.hs @@ -285,6 +285,18 @@ prProductions prods = maxLHSWidth = maximum $ 0:(map (length . fst) prods) rpad n s = s ++ replicate (n - length s) ' ' +prCFTerm :: CFTerm -> String +prCFTerm = pr 0 + where + pr p (CFObj f args) = paren p (prCId f ++ " (" ++ concat (intersperse "," (map (pr 0) args)) ++ ")") + pr p (CFAbs i t) = paren p ("\\x" ++ show i ++ ". " ++ pr 0 t) + pr p (CFApp t1 t2) = paren p (pr 1 t1 ++ "(" ++ pr 0 t2 ++ ")") + pr _ (CFRes i) = "$" ++ show i + pr _ (CFVar i) = "x" ++ show i + pr _ (CFMeta c) = "?" ++ prCId c + paren 0 x = x + paren 1 x = "(" ++ x ++ ")" + -- -- * CFRule Utilities -- |
