factor/basis/eval/eval.factor

27 lines
742 B
Factor
Raw Normal View History

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.
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
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
[
parser-quiet? on
'[ _ ( -- ) (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 )
[ (eval>string) ] with-file-vocabs ;