2009-01-27 05:11:43 -05:00
|
|
|
! Copyright (C) 2008, 2009 Slava Pestov.
|
2008-07-28 23:03:13 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2009-10-19 04:44:50 -04:00
|
|
|
USING: splitting parser parser.notes compiler.units kernel
|
|
|
|
namespaces debugger io.streams.string fry combinators
|
|
|
|
effects.parser continuations ;
|
2008-07-28 23:03:13 -04:00
|
|
|
IN: eval
|
|
|
|
|
2009-03-16 21:11:36 -04:00
|
|
|
: parse-string ( str -- quot )
|
2009-01-27 05:11:43 -05:00
|
|
|
[ string-lines parse-lines ] with-compilation-unit ;
|
|
|
|
|
2009-04-15 20:03:44 -04:00
|
|
|
: (eval) ( str effect -- )
|
|
|
|
[ parse-string ] dip call-effect ; inline
|
2009-01-27 05:11:43 -05:00
|
|
|
|
2009-04-15 20:03:44 -04:00
|
|
|
: eval ( str effect -- )
|
|
|
|
[ (eval) ] with-file-vocabs ; inline
|
|
|
|
|
2015-07-27 12:53:10 -04:00
|
|
|
SYNTAX: eval( \ eval parse-call-paren ;
|
2008-07-28 23:03:13 -04:00
|
|
|
|
2009-01-27 05:11:43 -05:00
|
|
|
: (eval>string) ( str -- output )
|
2008-07-28 23:03:13 -04:00
|
|
|
[
|
2011-09-06 19:29:15 -04:00
|
|
|
parser-quiet? on
|
2011-10-18 16:18:42 -04:00
|
|
|
'[ _ ( -- ) (eval) ] [ print-error ] recover
|
2008-07-28 23:03:13 -04:00
|
|
|
] with-string-writer ;
|
2009-01-27 05:11:43 -05:00
|
|
|
|
|
|
|
: eval>string ( str -- output )
|
2011-09-06 19:29:15 -04:00
|
|
|
[ (eval>string) ] with-file-vocabs ;
|