Convenience commands to run and debug after compiling from Kondey.
Chris Pressey
5 months ago
479 | 479 | more concise and readable (such as it is) fashion: |
480 | 480 | |
481 | 481 | +++++ |
482 | {+++++++++/+++++++++++++/+++++++} | |
482 | { | |
483 | +++++++++ | |
484 | / | |
485 | +++++++++++++ | |
486 | / | |
487 | +++++++ | |
488 | } | |
483 | 489 | -----<<< |
484 | 490 | ===> +++++(+++++++++>/>)(/)--(<---------+++++++++++++>>/>)--(/)----(<<-------------+++++++>>>/>)----(/)-----<<< |
491 | ||
492 | Once the Kondey program has been compiled to Burro, we can run the Burro, to further confirm | |
493 | the behaviour is what we expect. | |
494 | ||
495 | -> Tests for functionality "Compile and Run Kondey Program" | |
496 | ||
497 | -> Functionality "Compile and Run Kondey Program" is implemented by | |
498 | -> shell command "bin/burro run-kondey %(test-body-file)" | |
499 | ||
500 | +++++ | |
501 | { | |
502 | +++++++++ | |
503 | / | |
504 | +++++++++++++ | |
505 | / | |
506 | +++++++ | |
507 | } | |
508 | -----<<< | |
509 | ===> State{ tape=(... [7] ...), stack=(... [0] ...), halt=True } | |
510 | ||
511 | -> Tests for functionality "Compile Kondey Program" | |
485 | 512 | |
486 | 513 | Kondey conditional forms can be nested. That was, kind of, the whole point of definition Kondey; |
487 | 514 | without some syntax and some automatic translation, we would need to write these things by hand |
488 | 515 | in Burro, and that's horrible and we wanted to avoid that. |
489 | 516 | |
490 | {+++++++++/>>>>>{+/++}<<<<</+++++++} | |
517 | { | |
518 | +++++++++ | |
519 | / | |
520 | >>>>> | |
521 | { | |
522 | + | |
523 | / | |
524 | ++ | |
525 | } | |
526 | <<<<< | |
527 | / | |
528 | +++++++ | |
529 | } | |
491 | 530 | ===> (+++++++++>/>)(/)--(<--------->>>>>(+>/>)(/)--(<-++>>/>)--(/)<<<<<>>/>)--(/)----(<<>>>>>(/)++(</<<--+>)++(/)(</<-)<<<<<+++++++>>>/>)----(/) |
6 | 6 | import System.Environment |
7 | 7 | import Language.Burro.Definition |
8 | 8 | import qualified Language.Burro.Debugger as Debugger |
9 | import qualified Language.Kondey.Compiler as Compiler | |
9 | import qualified Language.Kondey.Compiler as KondeyCompiler | |
10 | 10 | |
11 | 11 | main = do |
12 | 12 | args <- getArgs |
20 | 20 | putStrLn $ show $ state |
21 | 21 | ["compile-kondey", fileName] -> do |
22 | 22 | kondeyText <- readFile fileName |
23 | let b :: Burro = Compiler.compile kondeyText | |
24 | putStrLn $ show $ trim b | |
23 | let burroProg :: Burro = KondeyCompiler.compile kondeyText | |
24 | putStrLn $ show $ trim burroProg | |
25 | ["run-kondey", fileName] -> do | |
26 | kondeyText <- readFile fileName | |
27 | let burroProg :: Burro = KondeyCompiler.compile kondeyText | |
28 | putStrLn $ show $ run burroProg newstate | |
29 | ["debug-kondey", fileName] -> do | |
30 | kondeyText <- readFile fileName | |
31 | let burroProg :: Burro = KondeyCompiler.compile kondeyText | |
32 | state <- Debugger.run burroProg newstate | |
33 | putStrLn $ show $ state | |
25 | 34 | _ -> do |
26 | 35 | putStrLn $ |
27 | 36 | "Usage:\n" ++ |
28 | 37 | " burro run <filename.burro>\n" ++ |
29 | 38 | " burro debug <filename.burro>\n" ++ |
30 | " burro compile-kondey <filename.kondey>\n" | |
39 | " burro compile-kondey <filename.kondey>\n" ++ | |
40 | " burro run-kondey <filename.kondey>\n" ++ | |
41 | " burro debug-kondey <filename.kondey>\n" |