Permalink
Browse files

Initial commit

  • Loading branch information...
mattgreen committed Jul 3, 2014
0 parents commit 79e34386f5a31ebd6ff7968c645eb485e75e508f
Showing with 35 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +25 −0 Hython.hs
  3. +3 −0 Makefile
  4. +4 −0 print.py
@@ -0,0 +1,3 @@
+*.hi
+*.o
+hython
@@ -0,0 +1,25 @@
+import System.Environment
+import Text.ParserCombinators.Parsec
+
+data Statement = Print String
+ deriving(Show)
+
+statement = do
+ string "print(\""
+ content <- many (noneOf "\"")
+ string "\")"
+ spaces
+ return $ Print content
+
+statements = many statement
+
+eval :: Statement -> IO ()
+eval (Print m) = print m
+
+main = do
+ [filename] <- getArgs
+ code <- readFile filename
+
+ case parse statements filename code of
+ Left e -> print e
+ Right r -> mapM_ eval r
@@ -0,0 +1,3 @@
+hython: Hython.hs
+ ghc Hython.hs -o hython
+
@@ -0,0 +1,4 @@
+print("Hello")
+
+
+print("This is a test")

0 comments on commit 79e3438

Please sign in to comment.