]> gitweb.factorcode.org Git - factor.git/blob - basis/eval/eval.factor
basis: use lint.vocabs tool to trim using lists
[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 combinators.smart compiler.units
4 continuations debugger effects.parser io.streams.string
5 kernel namespaces parser parser.notes prettyprint splitting ;
6 IN: eval
7
8 : parse-string ( str -- quot )
9     [ split-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 ;
27
28 : (eval-with-stack) ( str -- )
29     parse-string [ output>array datastack. ] call( quot -- ) ;
30
31 : eval-with-stack ( str -- )
32     [ (eval-with-stack) ] with-file-vocabs ;
33
34 : (eval-with-stack>string) ( str -- output )
35     [
36         parser-quiet? on
37         [ (eval-with-stack) ] [ nip print-error ] recover
38     ] with-string-writer ;
39
40 : eval-with-stack>string ( str -- output )
41     [ (eval-with-stack>string) ] with-file-vocabs ;