]> gitweb.factorcode.org Git - factor.git/commitdiff
docs and metadata for literals
authorJoe Groff <arcata@gmail.com>
Fri, 12 Dec 2008 07:00:23 +0000 (23:00 -0800)
committerJoe Groff <arcata@gmail.com>
Fri, 12 Dec 2008 07:00:23 +0000 (23:00 -0800)
extra/literals/authors.txt [new file with mode: 0644]
extra/literals/literals-docs.factor [new file with mode: 0644]
extra/literals/literals-tests.factor
extra/literals/literals.factor
extra/literals/summary.txt [new file with mode: 0644]
extra/literals/tags.txt [new file with mode: 0644]

diff --git a/extra/literals/authors.txt b/extra/literals/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/extra/literals/literals-docs.factor b/extra/literals/literals-docs.factor
new file mode 100644 (file)
index 0000000..ae25c75
--- /dev/null
@@ -0,0 +1,61 @@
+! Copyright (C) 2008 Joe Groff.
+! See http://factorcode.org/license.txt for BSD license.
+USING: help.markup help.syntax multiline ;
+IN: literals
+
+HELP: $
+{ $syntax "$ word" }
+{ $description "Executes " { $snippet "word" } " at parse time and adds the result(s) to the parser accumulator." }
+{ $notes "Since " { $snippet "word" } " is executed at parse time, " { $snippet "$" } " cannot be used with words defined in the same compilation unit." }
+{ $examples
+
+    { $example <"
+USING: kernel literals prettyprint ;
+IN: scratchpad
+
+<< : five 5 ; >>
+{ $ five } .
+    "> "{ 5 }" }
+
+    { $example <"
+USING: kernel literals prettyprint ;
+IN: scratchpad
+
+<< : seven-eleven 7 11 ; >>
+{ $ seven-eleven } .
+    "> "{ 7 11 }" }
+
+} ;
+
+HELP: $[
+{ $syntax "$[ code ]" }
+{ $description "Calls " { $snippet "code" } " at parse time and adds the result(s) to the parser accumulator." }
+{ $notes "Since " { $snippet "code" } " is executed at parse time, it cannot reference any words defined in the same compilation unit." }
+{ $examples
+
+    { $example <"
+USING: kernel literals math prettyprint ;
+IN: scratchpad
+
+<< : five 5 ; >>
+{ $[ five dup 1+ dup 2 + ] } .
+    "> "{ 5 6 8 }" }
+
+} ;
+
+{ POSTPONE: $ POSTPONE: $[ } related-words
+
+ARTICLE: "literals" "Interpolating code results into literal values"
+"The " { $vocab-link "literals" } " vocabulary contains words to run code at parse time and insert the results into more complex literal values."
+{ $example <"
+USING: kernel literals math prettyprint ;
+IN: scratchpad
+
+<< : five 5 ; >>
+{ $ five $[ five dup 1+ dup 2 + ] } .
+    "> "{ 5 5 6 8 }" }
+{ $subsection POSTPONE: $ }
+{ $subsection POSTPONE: $[ }
+;
+
+ABOUT: "literals"
index b88a286a59679a480760e4ae6028675b7b22351d..185d672dd3fb5f5a4319f1fed7d6e1190a16cee9 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel literals tools.test ;
+USING: kernel literals math tools.test ;
 IN: literals.tests
 
 <<
@@ -10,3 +10,5 @@ IN: literals.tests
 [ { 5 } ] [ { $ five } ] unit-test
 [ { 7 11 } ] [ { $ seven-eleven } ] unit-test
 [ { 6 6 6 } ] [ { $ six-six-six } ] unit-test
+
+[ { 8 8 8 } ] [ { $[ six-six-six [ 2 + ] tri@ ] } ] unit-test
index d46f492cd4a52708a86fd36edc1256b36882fdbb..a450c2118e3df4524651e7714aba9c3fe8952bb2 100644 (file)
@@ -1,4 +1,6 @@
-USING: continuations kernel parser words ;
+! (c) Joe Groff, see license for details
+USING: continuations kernel parser words quotations ;
 IN: literals
 
 : $ scan-word [ execute ] curry with-datastack ; parsing
+: $[ \ ] parse-until >quotation with-datastack ; parsing
diff --git a/extra/literals/summary.txt b/extra/literals/summary.txt
new file mode 100644 (file)
index 0000000..dfeb9fe
--- /dev/null
@@ -0,0 +1 @@
+Expression interpolation into sequence literals
diff --git a/extra/literals/tags.txt b/extra/literals/tags.txt
new file mode 100644 (file)
index 0000000..71c0ff7
--- /dev/null
@@ -0,0 +1 @@
+syntax