}
{ $errors "Throws an error if the input is malformed, or if the evaluation itself throws an error." } ;
+HELP: eval-with-stack
+{ $values { "str" string } { "output" string } }
+{ $description "Parses Factor source code from " { $snippet "str" } ", and then calls the resulting quotation, and then prints the data stack if any objects are left." } ;
+
HELP: eval>string
{ $values { "str" string } { "output" string } }
{ $description "Evaluates the Factor code in " { $snippet "str" } " with " { $link output-stream } " rebound to a string output stream, then outputs the resulting string. The code in the string must not take or leave any values on the stack." }
! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: combinators compiler.units continuations debugger
-effects.parser io.streams.string kernel namespaces parser
-parser.notes splitting ;
+USING: combinators combinators.smart compiler.units
+continuations debugger effects.parser io io.streams.string
+kernel namespaces parser parser.notes prettyprint sequences
+splitting ;
IN: eval
: parse-string ( str -- quot )
: eval>string ( str -- output )
[ (eval>string) ] with-file-vocabs ;
+
+: (eval-with-stack) ( str -- output )
+ [
+ [
+ parser-quiet? on parse-string [
+ output>array [
+ nl "--- Data stack:" print stack.
+ ] unless-empty
+ ] call( quot -- )
+ ] [ nip print-error ] recover
+ ] with-string-writer ;
+
+: eval-with-stack ( str -- output )
+ [ (eval-with-stack) ] with-file-vocabs ;
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes classes.struct
-classes.tuple combinators combinators.short-circuit
-combinators.smart continuations debugger definitions effects
-eval formatting fry grouping help help.markup help.topics io
-io.streams.string kernel macros math math.statistics namespaces
-parser.notes prettyprint sequences sequences.deep sets splitting
-strings summary tools.destructors unicode vocabs vocabs.loader
-words words.constant words.symbol ;
+classes.tuple combinators combinators.short-circuit debugger
+definitions effects eval formatting grouping help help.markup
+help.topics io io.streams.string kernel macros math
+math.statistics namespaces prettyprint sequences sequences.deep
+sets splitting strings summary tools.destructors unicode vocabs
+vocabs.loader words words.constant words.symbol ;
IN: help.lint.checks
ERROR: simple-lint-error message ;
} member?
] reject ;
-: eval-with-stack ( str -- output )
- [
- [
- parser-quiet? on parse-string [
- output>array [
- nl "--- Data stack:" print stack.
- ] unless-empty
- ] call( quot -- )
- ] [ nip print-error ] recover
- ] with-string-writer ;
-
: check-example ( element -- )
[
'[