1 ! Copyright (C) 2009 Jose Antonio Ortega Ruiz.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays continuations debugger fuel.pprint io io.streams.string
4 kernel listener namespaces prettyprint.config sequences vocabs.parser
9 V{ } clone restarts-stack set-global
12 f eval-error set-global
15 f eval-result set-global
18 f eval-output set-global
21 t eval-res-flag set-global
23 : eval-restartable? ( -- ? )
24 eval-res-flag get-global ;
27 restarts get-global clone restarts-stack get push ;
29 : pop-restarts ( restarts -- )
30 eval-restartable? [ drop ] [ clone restarts set-global ] if ;
33 restarts-stack get [ pop pop-restarts ] unless-empty ;
37 eval-result get-global
38 eval-output get-global 3array
39 [ fuel-pprint ] without-limits
40 flush nl "<~FUEL~>" write nl flush ;
44 f eval-error set-global
45 f eval-result set-global
46 f eval-output set-global ;
48 : end-eval ( output -- )
49 eval-output set-global send-retort pop-status ;
52 [ parse-lines-interactive call( -- ) ] curry
53 [ [ eval-error set-global ] [ print-error ] bi ] recover ;
55 : eval-usings ( usings -- )
56 [ [ use-vocab ] curry ignore-errors ] each ;
59 [ set-current-vocab ] when* ;
61 : eval-in-context ( lines in usings -- )
64 { "fuel" "syntax" } prepend
65 <manifest> manifest set
66 [ eval-usings eval-in eval ] with-string-writer
67 ] with-scope end-eval ;