]> gitweb.factorcode.org Git - factor.git/blob - basis/eval/eval.factor
a2166cfa4cebca8c7a7e599246afc458cc81d278
[factor.git] / basis / eval / eval.factor
1 ! Copyright (C) 2008, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators compiler.units continuations debugger
4 effects.parser io.streams.string kernel namespaces parser
5 parser.notes splitting ;
6 IN: eval
7
8 : parse-string ( str -- quot )
9     [ string-lines parse-lines ] with-compilation-unit ;
10
11 : (eval) ( str effect -- )
12     [ parse-string ] dip call-effect ; inline
13
14 : eval ( str effect -- )
15     [ (eval) ] with-file-vocabs ; inline
16
17 SYNTAX: eval( \ eval parse-call-paren ;
18
19 : (eval>string) ( str -- output )
20     [
21         parser-quiet? on
22         '[ _ ( -- ) (eval) ] [ print-error ] recover
23     ] with-string-writer ;
24
25 : eval>string ( str -- output )
26     [ (eval>string) ] with-file-vocabs ;