Index: /hh2008/ujihisa/Rakefile
===================================================================
--- /hh2008/ujihisa/Rakefile (revision 16)
+++ /hh2008/ujihisa/Rakefile (revision 16)
@@ -0,0 +1,5 @@
+task :default do
+  sh "runghc uhc.hs < sample.hs"
+end
+
+
Index: /hh2008/ujihisa/uhc.hs
===================================================================
--- /hh2008/ujihisa/uhc.hs (revision 16)
+++ /hh2008/ujihisa/uhc.hs (revision 16)
@@ -0,0 +1,51 @@
+module Main (main) where
+
+import Text.ParserCombinators.Parsec
+
+p :: Parser Module
+p = do spaces
+       string "module"
+       spaces
+       modid <- do { c <- upper; cs <- many lower; return $ c:cs }
+       spaces
+       string "where"
+       spaces
+       body <- pBody
+       return $ Module modid [] body
+  where
+    pBody :: Parser Body
+    pBody = do char '{'
+               bs <- many pBodyLine
+               spaces
+               char '}'
+               return $ Body bs
+    pBodyLine :: Parser TopDecl
+    pBodyLine = many (noneOf "\n}") >> ((try pGenDecl) <|> (try pFunctionLHS))
+      where
+        pGenDecl = do spaces
+                      name <- many lower
+                      spaces
+                      string "::"
+                      spaces
+                      cs <- many1 $ noneOf "\n"
+                      return $ TopDecl $ GenDecl name cs
+        pFunctionLHS = do spaces
+                          name <- many lower
+                          spaces
+                          string "="
+                          spaces
+                          cs <- many1 $ noneOf "\n"
+                          return $ TopDecl $ FunctionLHS name cs
+
+compile :: String -> String
+compile str = case parse p "" str of
+                Right exp -> show exp
+                Left err -> "Error -- " ++ show err
+
+main = do cs <- getContents
+          putStrLn $ compile cs
+
+data Module = Module String [String] Body deriving Show
+data Body = Body [TopDecl] deriving Show
+data TopDecl = TopDecl Decl | NotImplemented deriving Show
+data Decl = GenDecl String String | FunctionLHS String String deriving Show
Index: /hh2008/ujihisa/sample.hs
===================================================================
--- /hh2008/ujihisa/sample.hs (revision 16)
+++ /hh2008/ujihisa/sample.hs (revision 16)
@@ -0,0 +1,6 @@
+module Main where {
+  main :: IO ()
+  main = putStrLn "1"
+  add :: Int -> Int -> Int
+  add = (+)
+}
