Push buildProgram further down.
Chris Pressey
3 months ago
3 | 3 |
|
4 | 4 |
import Language.Turmac.Model
|
5 | 5 |
import Language.Turmac.IR
|
|
6 |
import Language.Turmac.IRCompiler
|
6 | 7 |
|
7 | |
compileToPython :: Prog -> String
|
8 | |
compileToPython prog = unlines [
|
|
8 |
compileToPython :: [TMRule] -> String
|
|
9 |
compileToPython tmRules = let prog = buildProgram tmRules in unlines [
|
9 | 10 |
"class Tape:",
|
10 | 11 |
" def __init__(self, initial_input=None):",
|
11 | 12 |
" self.left_cells = []",
|
61 | 61 |
else Right $ rules
|
62 | 62 |
parse False input = Right $ parseRules input
|
63 | 63 |
|
|
64 |
compileTo :: String -> ([TMRule] -> String)
|
64 | 65 |
compileTo "python" = compileToPython
|
65 | 66 |
compileTo _ = error "--backend must be given when compiling, and must be one of: 'python'"
|
66 | 67 |
|
|
109 | 110 |
turmacText <- readFile fileName
|
110 | 111 |
case parse (checkComplete flags) turmacText of
|
111 | 112 |
Right tmRules -> do
|
112 | |
putStr $ compileTo (backend flags) $ buildProgram tmRules
|
|
113 |
putStr $ compileTo (backend flags) tmRules
|
113 | 114 |
exitWith ExitSuccess
|
114 | 115 |
|
115 | 116 |
Left errMsg -> do
|