]> gitweb.factorcode.org Git - factor.git/commitdiff
code annotations toy
authorJoe Groff <arcata@gmail.com>
Thu, 12 Feb 2009 00:35:08 +0000 (18:35 -0600)
committerJoe Groff <arcata@gmail.com>
Thu, 12 Feb 2009 00:35:08 +0000 (18:35 -0600)
extra/annotations/annotations.factor [new file with mode: 0644]
extra/annotations/authors.txt [new file with mode: 0644]
extra/annotations/summary.txt [new file with mode: 0644]
extra/annotations/tags.txt [new file with mode: 0644]

diff --git a/extra/annotations/annotations.factor b/extra/annotations/annotations.factor
new file mode 100644 (file)
index 0000000..5102a36
--- /dev/null
@@ -0,0 +1,41 @@
+! (c)2009 Joe Groff, Doug Coleman. see BSD license
+USING: accessors combinators.short-circuit definitions functors
+kernel lexer namespaces parser prettyprint sequences words ;
+IN: annotations
+
+<<
+
+: (parse-annotation) ( accum -- accum )
+    lexer get [ line-text>> parsed ] [ next-line ] bi ;
+
+: (non-annotation-usage) ( word -- usages )
+    smart-usage
+    [ { [ word? ] [ vocabulary>> "annotations" = not ] } 1&& ]
+    filter ;
+
+FUNCTOR: define-annotation ( NAME -- )
+
+(NAME) DEFINES (${NAME})
+!NAME  DEFINES !${NAME}
+NAMEs  DEFINES ${NAME}s
+NAMEs. DEFINES ${NAME}s.
+
+WHERE
+
+: (NAME) ( str -- ) drop ; inline
+: !NAME (parse-annotation) \ (NAME) parsed ; parsing
+
+: NAMEs ( -- usages )
+    \ (NAME) (non-annotation-usage) ;
+: NAMEs. ( -- )
+    NAMEs sorted-definitions. ;
+
+;FUNCTOR
+
+{
+    "XXX" "TODO" "FIXME" "BUG" "REVIEW" "LICENSE"
+    "AUTHOR" "BROKEN" "HACK" "LOL" "NOTE"
+} [ define-annotation ] each
+
+>>
+
diff --git a/extra/annotations/authors.txt b/extra/annotations/authors.txt
new file mode 100644 (file)
index 0000000..0bc3c5a
--- /dev/null
@@ -0,0 +1,2 @@
+Joe Groff
+Doug Coleman
diff --git a/extra/annotations/summary.txt b/extra/annotations/summary.txt
new file mode 100644 (file)
index 0000000..732ed6f
--- /dev/null
@@ -0,0 +1 @@
+Code annotation comment syntax
diff --git a/extra/annotations/tags.txt b/extra/annotations/tags.txt
new file mode 100644 (file)
index 0000000..278296d
--- /dev/null
@@ -0,0 +1,2 @@
+comments
+annotation