diff --git a/basis/eval/eval-docs.factor b/basis/eval/eval-docs.factor index 057d291b7f..b53c3bae6b 100644 --- a/basis/eval/eval-docs.factor +++ b/basis/eval/eval-docs.factor @@ -11,7 +11,7 @@ HELP: eval>string { $description "Evaluates the Factor code in " { $snippet "str" } " with " { $link output-stream } " rebound to a string output stream, then outputs the resulting string." } ; ARTICLE: "eval" "Evaluating strings at runtime" -"Evaluating strings at runtime:" +"The " { $vocab-link "eval" } " vocabulary implements support for evaluating strings at runtime." { $subsection eval } { $subsection eval>string } ; diff --git a/basis/eval/eval-tests.factor b/basis/eval/eval-tests.factor new file mode 100644 index 0000000000..db4b95acdc --- /dev/null +++ b/basis/eval/eval-tests.factor @@ -0,0 +1,4 @@ +IN: eval.tests +USING: eval tools.test ; + +[ "4\n" ] [ "USING: math prettyprint ; 2 2 + ." eval>string ] unit-testv \ No newline at end of file diff --git a/basis/eval/eval.factor b/basis/eval/eval.factor index 5b22fec159..dfa9baf418 100644 --- a/basis/eval/eval.factor +++ b/basis/eval/eval.factor @@ -1,14 +1,24 @@ -! Copyright (C) 2008 Slava Pestov. +! Copyright (C) 2008, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: splitting parser compiler.units kernel namespaces -debugger io.streams.string ; +debugger io.streams.string fry ; IN: eval +: parse-string ( str -- ) + [ string-lines parse-lines ] with-compilation-unit ; + +: (eval) ( str -- ) + parse-string call ; + : eval ( str -- ) - [ string-lines parse-fresh ] with-compilation-unit call ; + [ (eval) ] with-file-vocabs ; + +: (eval>string) ( str -- output ) + [ + "quiet" on + parser-notes off + '[ _ (eval) ] try + ] with-string-writer ; : eval>string ( str -- output ) - [ - parser-notes off - [ [ eval ] keep ] try drop - ] with-string-writer ; + [ (eval>string) ] with-file-vocabs ; \ No newline at end of file diff --git a/basis/help/lint/lint.factor b/basis/help/lint/lint.factor index 4424b52711..e7c93d934d 100644 --- a/basis/help/lint/lint.factor +++ b/basis/help/lint/lint.factor @@ -9,15 +9,17 @@ continuations classes.predicate macros math sets eval vocabs.parser words.symbol values ; IN: help.lint +SYMBOL: vocabs-quot + : check-example ( element -- ) - rest [ - but-last "\n" join 1vector - [ - use [ clone ] change - [ eval>string ] with-datastack - ] with-scope peek "\n" ?tail drop - ] keep - peek assert= ; + [ + rest [ + but-last "\n" join 1vector + [ (eval>string) ] with-datastack + peek "\n" ?tail drop + ] keep + peek assert= + ] vocabs-quot get call ; : check-examples ( element -- ) \ $example swap elements [ check-example ] each ; @@ -79,46 +81,44 @@ IN: help.lint ] each ; : check-rendering ( element -- ) - [ print-topic ] with-string-writer drop ; + [ print-content ] with-string-writer drop ; + +: check-markup ( element -- ) + [ check-rendering ] + [ check-examples ] + [ check-modules ] + tri ; : all-word-help ( words -- seq ) [ word-help ] filter ; -TUPLE: help-error topic error ; +TUPLE: help-error error topic ; C: help-error M: help-error error. - "In " write dup topic>> pprint nl - error>> error. ; + [ "In " write topic>> pprint nl ] + [ error>> error. ] + bi ; : check-something ( obj quot -- ) - flush [ , ] recover ; inline + flush '[ _ assert-depth ] swap '[ _ , ] recover ; inline : check-word ( word -- ) + [ with-file-vocabs ] vocabs-quot set dup word-help [ - [ - dup word-help '[ - _ _ { - [ check-values ] - [ nip [ check-examples ] [ check-see-also ] bi ] - [ [ check-rendering ] [ check-modules ] bi* ] - } 2cleave - ] assert-depth + dup '[ + _ dup word-help + [ check-values ] + [ nip [ check-see-also ] [ check-markup ] bi ] 2bi ] check-something ] [ drop ] if ; : check-words ( words -- ) [ check-word ] each ; : check-article ( article -- ) - [ - dup article-content - '[ - _ check-rendering - _ [ check-modules ] [ check-examples ] bi - ] - assert-depth - ] check-something ; + [ with-interactive-vocabs ] vocabs-quot set + dup '[ _ article-content check-markup ] check-something ; : files>vocabs ( -- assoc ) vocabs @@ -137,7 +137,7 @@ M: help-error error. ] keep ; : check-about ( vocab -- ) - [ vocab-help [ article drop ] when* ] check-something ; + dup '[ _ vocab-help [ article drop ] when* ] check-something ; : check-vocab ( vocab -- seq ) "Checking " write dup write "..." print