]> gitweb.factorcode.org Git - factor.git/commitdiff
literate: adding some literate programming ideas.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 29 Aug 2012 19:17:25 +0000 (12:17 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 29 Aug 2012 19:17:25 +0000 (12:17 -0700)
extra/literate/authors.txt [new file with mode: 0644]
extra/literate/literate.factor [new file with mode: 0644]
extra/literate/summary.txt [new file with mode: 0644]

diff --git a/extra/literate/authors.txt b/extra/literate/authors.txt
new file mode 100644 (file)
index 0000000..e091bb8
--- /dev/null
@@ -0,0 +1 @@
+John Benediktsson
diff --git a/extra/literate/literate.factor b/extra/literate/literate.factor
new file mode 100644 (file)
index 0000000..054cb16
--- /dev/null
@@ -0,0 +1,25 @@
+! Copyright (C) 2012 John Benediktsson
+! See http://factorcode.org/license.txt for BSD license
+USING: accessors combinators.short-circuit compiler.units kernel
+lexer math multiline parser sequences splitting ;
+
+IN: literate
+
+TUPLE: literate-lexer < lexer ;
+
+: <literate-lexer> ( text -- lexer ) literate-lexer new-lexer ;
+
+M: literate-lexer skip-blank
+    dup column>> zero? [
+        dup line-text>> [
+            "> " head?
+            [ [ 2 + ] change-column call-next-method ]
+            [ [ nip length ] change-lexer-column ]
+            if
+        ] [ drop ] if*
+    ] [ call-next-method ] if ;
+
+SYNTAX: <LITERATE
+    "LITERATE>" parse-multiline-string string-lines [
+        <literate-lexer> (parse-lines) over push-all
+    ] with-nested-compilation-unit ;
diff --git a/extra/literate/summary.txt b/extra/literate/summary.txt
new file mode 100644 (file)
index 0000000..c8384e2
--- /dev/null
@@ -0,0 +1 @@
+Literate programming techniques