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