consumer_source_bundle_run.tri (1138B)
1 -- Runnable source-to-consumer compiler from a separately packed bundle. 2 !import "source.module" !Local 3 !import "consumers.structural" SCP 4 !import "consumers.fizzbuzz" F 5 !import "parser" P 6 !import "io" !Local 7 !import "prelude" !Local 8 root = "__ROOT__" 9 main = io (onResult_ (readFile "demos/consumers/fizzbuzz/fizzbuzz.scp") 10 (problem : putStrLn (append "read-error: " problem)) 11 (source : onResult_ (sourceModuleLoadSelected root "consumerBaseSourceCompiler" "compileBaseSource") 12 (problem : putStrLn (append "load-error: " problem)) 13 (compile : lazyResult 14 (diagnostic _ : putStrLn (append "compile-error=" (showNumber (P.parserDiagnosticCode diagnostic)))) 15 (compiled _ : lazyBool 16 (_ : putStrLn "consumer-source-bundle-ok") 17 (_ : putStrLn "consumer-source-bundle-wrong") 18 (and? (equal? (fst compiled) "fizzbuzz") 19 (and? (equal? (SCP.makeConsumer (pair 2 4) (snd (snd compiled))) 20 F.fizzbuzz) 21 (equal? (resultOr t (SCP.runConsumer 22 (SCP.makeConsumer (pair 2 4) (snd (snd compiled))) F.input)) 23 F.expected)))) 24 (compile source)))) 25 main