From 11dcb41546c6aaba1d04c03d9e97e6fce23b48bb Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 12 Jan 2008 20:30:43 -1000 Subject: [PATCH] refactor lint, add lint-vocab/lint-word --- extra/lint/lint.factor | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/extra/lint/lint.factor b/extra/lint/lint.factor index 37209182a0..44b234b254 100644 --- a/extra/lint/lint.factor +++ b/extra/lint/lint.factor @@ -121,7 +121,7 @@ M: word lint ( word -- seq ) : word-path. ( word -- ) [ word-vocabulary ":" ] keep unparse 3append write nl ; -: lint. ( array -- ) +: (lint.) ( pair -- ) first2 >r word-path. r> [ bl bl bl bl dup . @@ -129,6 +129,9 @@ M: word lint ( word -- seq ) def-hash get at [ bl bl bl bl word-path. ] each nl ] each nl nl ; + +: lint. ( alist -- ) + [ (lint.) ] each ; GENERIC: run-lint ( obj -- obj ) @@ -143,21 +146,29 @@ GENERIC: run-lint ( obj -- obj ) : trim-self ( seq -- newseq ) [ [ (trim-self) ] subset ] assoc-map ; +: filter-symbols ( alist -- alist ) + [ + nip first dup def-hash get at + [ first ] 2apply literalize = not + ] assoc-subset ; + M: sequence run-lint ( seq -- seq ) [ global [ dup . flush ] bind dup lint ] { } map>assoc trim-self - [ second empty? not ] subset ; + [ second empty? not ] subset + filter-symbols ; M: word run-lint ( word -- seq ) 1array run-lint ; : lint-all ( -- seq ) - all-words run-lint - [ - nip first dup def-hash get at - [ first ] 2apply literalize = not - ] assoc-subset - dup [ lint. ] each ; + all-words run-lint dup lint. ; + +: lint-vocab ( vocab -- seq ) + words run-lint dup lint. ; + +: lint-word ( word -- seq ) + 1array run-lint dup lint. ;