| 
									
										
										
										
											2011-11-06 01:34:21 -04:00
										 |  |  | ! Copyright (C) 2007, 2008, 2011 Doug Coleman. | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2011-10-16 22:32:16 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | USING: accessors alien arrays assocs classes | 
					
						
							| 
									
										
										
										
											2011-10-26 16:01:04 -04:00
										 |  |  | classes.tuple.private combinators.short-circuit continuations | 
					
						
							| 
									
										
										
										
											2014-06-04 12:10:23 -04:00
										 |  |  | fry hashtables io kernel kernel.private locals.backend make math | 
					
						
							|  |  |  | math.private namespaces prettyprint quotations sequences | 
					
						
							|  |  |  | sequences.deep shuffle slots.private splitting stack-checker | 
					
						
							|  |  |  | vectors vocabs words words.alias ;
 | 
					
						
							| 
									
										
										
										
											2011-10-16 22:32:16 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | IN: lint | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | <PRIVATE
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | CONSTANT: manual-substitutions | 
					
						
							|  |  |  |     H{ | 
					
						
							| 
									
										
										
										
											2008-12-18 01:42:12 -05:00
										 |  |  |         { -rot [ swap [ swap ] dip ] } | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  |         { -rot [ swap swapd ] } | 
					
						
							| 
									
										
										
										
											2008-12-18 01:42:12 -05:00
										 |  |  |         { rot [ [ swap ] dip swap ] } | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  |         { rot [ swapd swap ] } | 
					
						
							|  |  |  |         { over [ dup swap ] } | 
					
						
							| 
									
										
										
										
											2008-12-18 01:42:12 -05:00
										 |  |  |         { swapd [ [ swap ] dip ] } | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  |         { 2nip [ nip nip ] } | 
					
						
							|  |  |  |         { 2drop [ drop drop ] } | 
					
						
							|  |  |  |         { 3drop [ drop drop drop ] } | 
					
						
							|  |  |  |         { pop* [ pop drop ] } | 
					
						
							|  |  |  |         { when [ [ ] if ] } | 
					
						
							|  |  |  |         { >boolean [ f = not ] } | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-14 04:39:07 -04:00
										 |  |  | CONSTANT: trivial-defs | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2011-10-17 14:29:40 -04:00
										 |  |  |         [ ">" write ] [ "/>" write ] [ " " write ] | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |         [ 0 or + ] | 
					
						
							|  |  |  |         [ dup length iota ] | 
					
						
							|  |  |  |         [ 0 swap copy ] | 
					
						
							| 
									
										
										
										
											2011-10-17 14:29:40 -04:00
										 |  |  |         [ dup length ] | 
					
						
							|  |  |  |         [ 0 swap ] | 
					
						
							|  |  |  |         [ 2dup = ] [ 2dup eq? ] | 
					
						
							|  |  |  |         [ = not ] [ eq? not ] | 
					
						
							|  |  |  |         [ boa throw ] | 
					
						
							|  |  |  |         [ with each ] [ with map ] | 
					
						
							|  |  |  |         [ curry filter ] | 
					
						
							|  |  |  |         [ compose compose ] | 
					
						
							|  |  |  |         [ empty? ] [ empty? not ] | 
					
						
							|  |  |  |         [ dup empty? ] [ dup empty? not ] | 
					
						
							| 
									
										
										
										
											2014-06-04 12:10:23 -04:00
										 |  |  |         [ 2dup both-fixnums? ] | 
					
						
							|  |  |  |         [ [ drop ] prepose ] | 
					
						
							|  |  |  |         [ 1 0 ? ] | 
					
						
							| 
									
										
										
										
											2011-10-14 04:39:07 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | : lintable-word? ( word -- ? )
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         [ vocabulary>> "specialized-" head? ] | 
					
						
							|  |  |  |         [ vocabulary>> "windows-messages" = ] | 
					
						
							|  |  |  |         [ alias? ] | 
					
						
							|  |  |  |     } 1|| not ;
 | 
					
						
							| 
									
										
										
										
											2008-12-07 18:22:05 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | : lintable-words ( -- words )
 | 
					
						
							|  |  |  |     all-words [ lintable-word? ] filter ;
 | 
					
						
							| 
									
										
										
										
											2008-12-07 18:22:05 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | : ignore-def? ( def -- ? )
 | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ! Remove small defs | 
					
						
							| 
									
										
										
										
											2011-10-17 14:29:40 -04:00
										 |  |  |         [ length 1 <= ] | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         ! Remove trivial defs | 
					
						
							|  |  |  |         [ trivial-defs member? ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove curry only defs | 
					
						
							|  |  |  |         [ [ \ curry = ] all? ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove words with locals | 
					
						
							|  |  |  |         [ [ \ load-locals = ] any? ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-17 13:15:48 -04:00
										 |  |  |         ! Remove stuff with wrappers | 
					
						
							|  |  |  |         [ [ wrapper? ] any? ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-17 14:29:40 -04:00
										 |  |  |         ! Remove trivial math | 
					
						
							|  |  |  |         [ [ { [ number? ] [ { + - / * /i /f >integer } member? ] } 1|| ] all? ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove more trival defs | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 2 = ] | 
					
						
							|  |  |  |                 [ first2 [ word? ] either? ] | 
					
						
							|  |  |  |                 [ first2 [ { dip dup over swap drop } member? ] either? ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove [ V{ } clone ] and related | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 2 = ] | 
					
						
							|  |  |  |                 [ first { [ sequence? ] [ assoc? ] } 1|| ] | 
					
						
							| 
									
										
										
										
											2012-07-19 20:41:55 -04:00
										 |  |  |                 [ second { clone clone-like like assoc-like make } member? ] | 
					
						
							| 
									
										
										
										
											2011-10-17 14:29:40 -04:00
										 |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove [ foo get ] and related | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 2 = ] | 
					
						
							|  |  |  |                 [ first word? ] | 
					
						
							|  |  |  |                 [ second { get get-global , % } member? ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove [ first second ] and related | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 2 = ] | 
					
						
							|  |  |  |                 [ first { first second third } member? ] | 
					
						
							|  |  |  |                 [ second { first second third } member? ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove [ [ trivial ] if ] and related | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 2 = ] | 
					
						
							|  |  |  |                 [ first { [ quotation? ] [ ignore-def? ] } 1&& ] | 
					
						
							|  |  |  |                 [ second { if if* unless unless* when when* curry } member? ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove [ n - ] and related | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 2 = ] | 
					
						
							|  |  |  |                 [ first { [ number? ] [ boolean? ] } 1|| ] | 
					
						
							|  |  |  |                 [ second { + - / * < <= = >= > shift bitand bitor bitxor eq? } member? ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove [ dup 0 > ] and related | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 3 = ] | 
					
						
							|  |  |  |                 [ first { dup over } member? ] | 
					
						
							|  |  |  |                 [ second number? ] | 
					
						
							|  |  |  |                 [ third { + - / * < <= = >= > } member? ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove [ drop f f ] and related | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 4 <= ] | 
					
						
							|  |  |  |                 [ first { drop 2drop 3drop nip 2nip } member? ] | 
					
						
							|  |  |  |                 [ rest-slice [ boolean? ] all? ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove [ length 1 = ] and related | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 3 = ] | 
					
						
							|  |  |  |                 [ first \ length = ] | 
					
						
							|  |  |  |                 [ second number? ] | 
					
						
							|  |  |  |                 [ third { + - / * < <= = >= > } member? ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove [ dup length 1 = ] and related | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 4 = ] | 
					
						
							|  |  |  |                 [ first { dup over } member? ] | 
					
						
							|  |  |  |                 [ second \ length = ] | 
					
						
							|  |  |  |                 [ third number? ] | 
					
						
							|  |  |  |                 [ fourth { + - / * < <= = >= > } member? ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |         ! Remove numbers/t/f only defs | 
					
						
							|  |  |  |         [ | 
					
						
							| 
									
										
										
										
											2011-10-17 14:29:40 -04:00
										 |  |  |             [ { [ number? ] [ boolean? ] } 1|| ] all?
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 22:32:16 -04:00
										 |  |  |         ! Remove [ tag n eq? ] | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 3 = ] | 
					
						
							|  |  |  |                 [ first \ tag = ] [ second number? ] [ third \ eq? = ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-04 12:10:23 -04:00
										 |  |  |         ! Remove [ { foo } declare class-of ] | 
					
						
							| 
									
										
										
										
											2011-10-16 22:32:16 -04:00
										 |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 3 = ] | 
					
						
							|  |  |  |                 [ first { [ array? ] [ length 1 = ] } 1&& ] | 
					
						
							|  |  |  |                 [ second \ declare = ] | 
					
						
							| 
									
										
										
										
											2014-06-04 12:10:23 -04:00
										 |  |  |                 [ third \ class-of = ] | 
					
						
							| 
									
										
										
										
											2011-10-16 22:32:16 -04:00
										 |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |         ! Remove [ m n shift ] | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 3 = ] | 
					
						
							|  |  |  |                 [ first2 [ number? ] both? ] [ third \ shift = ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ! Remove [ layout-of n slot ] | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 [ length 3 = ] | 
					
						
							|  |  |  |                 [ first \ layout-of = ] | 
					
						
							|  |  |  |                 [ second number? ] | 
					
						
							|  |  |  |                 [ third \ slot = ] | 
					
						
							|  |  |  |             } 1&& | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  |     } 1|| ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : all-callables ( def -- seq )
 | 
					
						
							| 
									
										
										
										
											2011-10-16 22:32:16 -04:00
										 |  |  |     [ { [ callable? ] [ ignore-def? not ] } 1&& ] deep-filter ;
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : (load-definitions) ( word def hash -- )
 | 
					
						
							|  |  |  |     [ all-callables ] dip '[ _ push-at ] with each ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : load-definitions ( words -- hash )
 | 
					
						
							|  |  |  |     H{ } clone [ '[ dup def>> _ (load-definitions) ] each ] keep ;
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | SYMBOL: lint-definitions | 
					
						
							|  |  |  | SYMBOL: lint-definitions-keys | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | : reload-definitions ( -- )
 | 
					
						
							|  |  |  |     ! Load lintable and non-ignored definitions | 
					
						
							|  |  |  |     lintable-words load-definitions | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |     ! Remove words that are their own definition | 
					
						
							|  |  |  |     [ [ [ def>> ] [ 1quotation ] bi = not ] filter ] assoc-map
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |     ! Add manual definitions | 
					
						
							|  |  |  |     manual-substitutions over '[ _ push-at ] assoc-each
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |     ! Set globals to new values | 
					
						
							|  |  |  |     [ lint-definitions set-global ] | 
					
						
							|  |  |  |     [ keys lint-definitions-keys set-global ] bi ;
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : find-duplicates ( -- seq )
 | 
					
						
							| 
									
										
										
										
											2011-10-14 04:39:07 -04:00
										 |  |  |     lint-definitions get-global [ nip length 1 > ] assoc-filter ;
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | GENERIC: lint ( obj -- seq )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: object lint ( obj -- seq ) drop f ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: callable lint ( quot -- seq )
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |     [ lint-definitions-keys get-global ] dip '[ _ subseq? ] filter ;
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | M: word lint ( word -- seq/f )
 | 
					
						
							| 
									
										
										
										
											2011-10-17 13:15:48 -04:00
										 |  |  |     def>> [ callable? ] deep-filter [ lint ] map concat ;
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : word-path. ( word -- )
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |     [ vocabulary>> write ":" write ] [ . ] bi ;
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : 4bl ( -- ) bl bl bl bl ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : (lint.) ( pair -- )
 | 
					
						
							|  |  |  |     first2 [ word-path. ] dip [ | 
					
						
							|  |  |  |         [ 4bl .  "-----------------------------------" print ] | 
					
						
							| 
									
										
										
										
											2011-10-14 04:39:07 -04:00
										 |  |  |         [ lint-definitions get-global at [ 4bl word-path. ] each nl ] bi
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  |     ] each nl ;
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : lint. ( alist -- ) [ (lint.) ] each ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GENERIC: run-lint ( obj -- obj )
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : (trim-self) ( val key -- obj ? )
 | 
					
						
							| 
									
										
										
										
											2011-10-14 04:39:07 -04:00
										 |  |  |     lint-definitions get-global at*
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  |     [ dupd remove empty? not ] [ drop f ] if ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : trim-self ( seq -- newseq )
 | 
					
						
							|  |  |  |     [ [ (trim-self) ] filter ] assoc-map ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : filter-symbols ( alist -- alist )
 | 
					
						
							|  |  |  |     [ | 
					
						
							| 
									
										
										
										
											2011-10-14 04:39:07 -04:00
										 |  |  |         nip first dup lint-definitions get-global at
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  |         [ first ] bi@ literalize = not
 | 
					
						
							|  |  |  |     ] assoc-filter ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: sequence run-lint ( seq -- seq )
 | 
					
						
							|  |  |  |     [ dup lint ] { } map>assoc trim-self | 
					
						
							|  |  |  |     [ second empty? not ] filter filter-symbols ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | M: word run-lint ( word -- seq ) 1array run-lint ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | PRIVATE>
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-26 16:01:04 -04:00
										 |  |  | : find-swap/swap ( word -- ? )
 | 
					
						
							|  |  |  |     def>> [ callable? ] deep-filter | 
					
						
							|  |  |  |     [ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             [ [ \ swap = ] count 2 >= ] | 
					
						
							|  |  |  |             [ | 
					
						
							|  |  |  |                 { swap } split rest but-last
 | 
					
						
							|  |  |  |                 [ [ infer ] [ 2drop ( -- ) ] recover ( x -- x ) = ] any?
 | 
					
						
							|  |  |  |             ] | 
					
						
							|  |  |  |         } 1&& | 
					
						
							|  |  |  |     ] any? ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-06 22:33:07 -05:00
										 |  |  | : find-redundant-word-props ( -- seq )
 | 
					
						
							|  |  |  |     all-words [ | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             [ { [ foldable? ] [ flushable? ] } 1|| ] | 
					
						
							|  |  |  |             [ inline? ] | 
					
						
							|  |  |  |         } 1&& | 
					
						
							|  |  |  |     ] filter ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | : lint-all ( -- seq )
 | 
					
						
							|  |  |  |     all-words run-lint dup lint. ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : lint-vocab ( vocab -- seq )
 | 
					
						
							|  |  |  |     words run-lint dup lint. ;
 | 
					
						
							| 
									
										
										
										
											2008-12-07 02:55:19 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-14 13:23:52 -04:00
										 |  |  | : lint-vocabs ( prefix -- seq )
 | 
					
						
							|  |  |  |     [ vocabs ] dip [ head? ] curry filter [ lint-vocab ] map ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-16 16:01:36 -04:00
										 |  |  | : lint-word ( word -- seq )
 | 
					
						
							|  |  |  |     1array run-lint dup lint. ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | reload-definitions |