help-lint doesn't check on value-words, this allows values to be documented. Also, make 'see' work with value words

db4
Slava Pestov 2009-01-16 14:12:10 -06:00
parent af998eb073
commit bfd2fcf750
2 changed files with 28 additions and 6 deletions

View File

@ -6,7 +6,7 @@ io io.streams.string prettyprint definitions arrays vectors
combinators combinators.short-circuit splitting debugger combinators combinators.short-circuit splitting debugger
hashtables sorting effects vocabs vocabs.loader assocs editors hashtables sorting effects vocabs vocabs.loader assocs editors
continuations classes.predicate macros math sets eval continuations classes.predicate macros math sets eval
vocabs.parser words.symbol ; vocabs.parser words.symbol values ;
IN: help.lint IN: help.lint
: check-example ( element -- ) : check-example ( element -- )
@ -42,12 +42,22 @@ IN: help.lint
$error-description $error-description
} swap '[ _ elements empty? not ] contains? ; } swap '[ _ elements empty? not ] contains? ;
: don't-check-word? ( word -- ? )
{
[ macro? ]
[ symbol? ]
[ value-word? ]
[ parsing-word? ]
[ "declared-effect" word-prop not ]
} 1|| ;
: check-values ( word element -- ) : check-values ( word element -- )
{ {
[ drop { [ symbol? ] [ macro? ] [ parsing-word? ] } 1|| ]
[ drop "declared-effect" word-prop not ]
[ nip contains-funky-elements? ]
[ [
[ don't-check-word? ]
[ contains-funky-elements? ]
bi* or
] [
[ effect-values >array ] [ effect-values >array ]
[ extract-values >array ] [ extract-values >array ]
bi* = bi* =

View File

@ -1,6 +1,7 @@
! Copyright (C) 2008 Daniel Ehrenberg. ! Copyright (C) 2008, 2009 Daniel Ehrenberg, Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel parser words sequences quotations ; USING: accessors kernel parser words sequences quotations
combinators.short-circuit definitions ;
IN: values IN: values
! Mutating literals in word definitions is not really allowed, ! Mutating literals in word definitions is not really allowed,
@ -22,12 +23,23 @@ TUPLE: value-holder < identity-tuple obj ;
PRIVATE> PRIVATE>
PREDICATE: value-word < word
def>> {
[ length 2 = ]
[ first value-holder? ]
[ second \ obj>> = ]
} 1&& ;
: VALUE: : VALUE:
CREATE-WORD CREATE-WORD
dup t "no-def-strip" set-word-prop dup t "no-def-strip" set-word-prop
T{ value-holder } clone [ obj>> ] curry T{ value-holder } clone [ obj>> ] curry
(( -- value )) define-declared ; parsing (( -- value )) define-declared ; parsing
M: value-word definer drop \ VALUE: f ;
M: value-word definition drop f ;
: set-value ( value word -- ) : set-value ( value word -- )
def>> first (>>obj) ; def>> first (>>obj) ;