]> gitweb.factorcode.org Git - factor.git/blob - extra/annotations/annotations.factor
factor: trim using lists
[factor.git] / extra / annotations / annotations.factor
1 ! (c)2009 Joe Groff, Doug Coleman. see BSD license
2 USING: accessors combinators.short-circuit functors kernel lexer
3 namespaces sequences tools.crossref words ;
4 IN: annotations
5
6 <<
7
8 : (parse-annotation) ( accum -- accum )
9     lexer get [ line-text>> suffix! ] [ next-line ] bi ;
10
11 : (non-annotation-usage) ( word -- usages )
12     smart-usage
13     [ { [ word? ] [ vocabulary>> "annotations" = ] } 1&& not ]
14     filter ;
15
16 <FUNCTOR: define-annotation ( NAME -- )
17
18 (NAME) DEFINES (${NAME})
19 !NAME  DEFINES !${NAME}
20 NAMEs  DEFINES ${NAME}s
21 NAMEs. DEFINES ${NAME}s.
22
23 WHERE
24
25 : (NAME) ( str -- ) drop ; inline
26 SYNTAX: !NAME (parse-annotation) \ (NAME) suffix! ;
27
28 : NAMEs ( -- usages )
29     \ (NAME) (non-annotation-usage) ;
30 : NAMEs. ( -- )
31     NAMEs sorted-definitions. ;
32
33 ;FUNCTOR>
34
35 CONSTANT: annotation-tags {
36     "XXX" "TODO" "FIXME" "BUG" "REVIEW" "LICENSE"
37     "AUTHOR" "BROKEN" "HACK" "LOL" "NOTE"
38 }
39
40 annotation-tags [ define-annotation ] each
41
42 >>