tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

consumer_layout_bundle_run.tri (1403B)


      1 -- Fresh-store run of a separately bundled interpreter and authored parser.
      2 !import "source.module" !Local
      3 !import "source.lexer" !Local
      4 !import "parser" !Local
      5 !import "io" !Local
      6 !import "prelude" !Local
      7 root = "__ROOT__"
      8 bodyTokens source = matchList t (_ rest :
      9   matchList t (_ remaining : remaining) rest) (parserReplyPayload (lexGateSource source))
     10 
     11 success run program = lazyResult (_ _ : false) (reply _ :
     12   and? (fst reply) (and? (parserReplyConsumed reply)
     13     (and? (not? (parserReplyCommitted reply))
     14       (and? (equal? (fst (parserReplyPayload reply)) 3)
     15         (equal? (parserReplyRest reply) t))))) (run program (bodyTokens "x =\n  y"))
     16 failure run program = lazyResult (_ _ : false) (reply _ :
     17   and? (not? (fst reply)) (and? (parserReplyConsumed reply)
     18     (and? (not? (parserReplyCommitted reply))
     19       (equal? (parserDiagnosticCode (parserReplyPayload reply)) 2)))) (run program (bodyTokens "x =\n  7"))
     20 
     21 main = io (onResult_ (sourceModuleLoadSelected root "layoutInterpreter" "runConsumer")
     22   (problem : putStrLn (append "interpreter-load-failed: " problem))
     23   (run : onResult_ (sourceModuleLoadSelected root "layoutProgram" "layout")
     24     (problem : putStrLn (append "layout-load-failed: " problem))
     25     (program : lazyBool
     26       (_ : putStrLn "layout-bundle-ok")
     27       (_ : putStrLn "layout-bundle-wrong-output")
     28       (and? (success run program) (failure run program)))))
     29 main