16 lines
424 B
Haskell
16 lines
424 B
Haskell
module Common where
|
|
import PythonAst
|
|
import PythonGen
|
|
import Text.Parsec
|
|
|
|
compile :: (String -> String -> Either ParseError p) -> (p -> [PyStmt]) -> String -> IO ()
|
|
compile p t f = do
|
|
let inputName = f ++ ".lang"
|
|
let outputName = f ++ ".py"
|
|
file <- readFile inputName
|
|
let either = p inputName file
|
|
case either of
|
|
Right prog -> writeFile outputName (translate $ t prog)
|
|
Left e -> print e
|
|
|