factor/extra/annotations/annotations.factor

45 lines
970 B
Factor
Raw Normal View History

2009-02-11 19:35:08 -05:00
! (c)2009 Joe Groff, Doug Coleman. see BSD license
USING: accessors combinators.short-circuit definitions functors
2009-03-07 02:22:21 -05:00
kernel lexer namespaces parser prettyprint tools.crossref
sequences words ;
2009-02-11 19:35:08 -05:00
IN: annotations
<<
: (parse-annotation) ( accum -- accum )
2009-10-28 14:38:27 -04:00
lexer get [ line-text>> suffix! ] [ next-line ] bi ;
2009-02-11 19:35:08 -05:00
: (non-annotation-usage) ( word -- usages )
smart-usage
[ { [ word? ] [ vocabulary>> "annotations" = ] } 1&& not ]
2009-02-11 19:35:08 -05:00
filter ;
FUNCTOR: define-annotation ( NAME -- )
(NAME) DEFINES (${NAME})
!NAME DEFINES !${NAME}
NAMEs DEFINES ${NAME}s
NAMEs. DEFINES ${NAME}s.
WHERE
: (NAME) ( str -- ) drop ; inline
2009-10-28 14:38:27 -04:00
SYNTAX: !NAME (parse-annotation) \ (NAME) suffix! ;
2009-02-11 19:35:08 -05:00
: NAMEs ( -- usages )
\ (NAME) (non-annotation-usage) ;
: NAMEs. ( -- )
NAMEs sorted-definitions. ;
;FUNCTOR
2009-02-11 20:58:28 -05:00
CONSTANT: annotation-tags {
2009-02-11 19:35:08 -05:00
"XXX" "TODO" "FIXME" "BUG" "REVIEW" "LICENSE"
"AUTHOR" "BROKEN" "HACK" "LOL" "NOTE"
2009-02-11 20:58:28 -05:00
}
annotation-tags [ define-annotation ] each
2009-02-11 19:35:08 -05:00
>>