factor/extra/annotations/annotations.factor

43 lines
1.1 KiB
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 kernel lexer
namespaces sequences tools.crossref words ;
FROM: functors2 => new-word \INLINE-FUNCTOR: ;
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 ;
2017-12-28 22:15:31 -05:00
INLINE-FUNCTOR: annotation ( name: new-word -- ) [[
USING: annotations kernel sequences tools.crossref ;
2009-02-11 19:35:08 -05:00
2017-12-28 22:15:31 -05:00
: (${name}) ( str -- ) drop ; inline
2009-02-11 19:35:08 -05:00
2017-12-28 22:15:31 -05:00
SYNTAX: !${name} (parse-annotation) \ (${name}) suffix! ;
2009-02-11 19:35:08 -05:00
2017-12-28 22:15:31 -05:00
: ${name}s ( -- usages )
\ (${name}) (non-annotation-usage) ;
2009-02-11 19:35:08 -05:00
2017-12-28 22:15:31 -05:00
: ${name}s. ( -- )
${name}s sorted-definitions. ;
]]
2009-02-11 19:35:08 -05:00
SYNTAX: \ANNOTATIONS: ";" [ define-annotation ] each-token ;
2009-02-11 19:35:08 -05:00
>>
! SYMBOLS: XXX TODO FIXME BUG REVIEW LICENSE
! AUTHOR BROKEN HACK LOL NOTE ;
! CONSTANT: annotation-tags {
! XXX TODO FIXME BUG REVIEW LICENSE
! AUTHOR BROKEN HACK LOL NOTE
! }
ANNOTATIONS: XXX TODO FIXME BUG REVIEW LICENSE AUTHOR BROKEN HACK LOL NOTE ;