update to sbp with regions in trees
[wix.git] / src / Wix.lhs
1 \begin{code}
2 -- Copyright 2008 the Contributors, as shown in the revision logs.
3 -- Licensed under the Apache Public Source License 2.0 ("the License").
4 -- You may not use this file except in compliance with the License.
5
6 module Wix(main')
7 where
8 import Edu_Berkeley_Sbp_Haskell_SBP
9 import FromTree
10 import Doc
11 import Html
12 import Foreign.Java
13 import qualified Text.PrettyPrint.Leijen as PP
14
15 process :: String -> IO String
16 process file = do t <- parseFile file
17                   return
18                    $ toHtml
19                     $ ((fromTree $ coalesceFlatHeadlessNodes t) :: Doc)
20
21 foreign import jvm safe "HaskellHelper.putBack" putBack :: JString -> IO ()
22
23 main' file verbosity =
24              do t <- parseFile file
25                 if verbosity > 0
26                   then
27                      putStrLn $ (PP.displayS
28                               $  PP.renderPretty (0.9) 80 
29                               $  prettyPrintTree (coalesceFlatHeadlessNodes t))
30                               ""
31                   else
32                      return ()
33                 doc <- return ((fromTree $ coalesceFlatHeadlessNodes t) :: Doc)
34                 if verbosity > 1
35                   then
36                      putStrLn $ (PP.displayS
37                               $  PP.renderPretty (0.9) 80 
38                               $  PP.pretty doc)
39                               ""
40                   else
41                      return ()
42                 js <- packJString $ toHtml doc
43                 putBack js
44
45 \end{code}
46
47
48
49