factor/basis/eval/eval.factor

26 lines
723 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.
2009-05-16 10:48:58 -04:00
USING: splitting parser parser.notes compiler.units kernel namespaces
2009-04-15 20:03:44 -04:00
debugger io.streams.string fry combinators effects.parser ;
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( ;
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
[
2009-01-27 05:11:43 -05:00
"quiet" on
2008-07-28 23:03:13 -04:00
parser-notes off
2009-04-15 20:03:44 -04:00
'[ _ (( -- )) (eval) ] try
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 ;