]> gitweb.factorcode.org Git - factor.git/blob - basis/multiline/multiline-docs.factor
0977acd1cd1a214283c48308f8be88bb2dda456b
[factor.git] / basis / multiline / multiline-docs.factor
1 USING: help.markup help.syntax ;
2 IN: multiline
3
4 HELP: STRING:
5 { $syntax "STRING: name\nfoo\n;" }
6 { $description "Forms a multiline string literal, or 'here document' stored in the word called name. A semicolon is used to signify the end, and that semicolon must be on a line by itself, not preceeded or followed by any whitespace. The string will have newlines in between lines but not at the end, unless there is a blank line before the semicolon." } ;
7
8 HELP: <"
9 { $syntax "<\" text \">" }
10 { $description "This forms a multiline string literal ending in \">. Unlike the " { $link POSTPONE: STRING: } " form, you can end it in the middle of a line. This construct is non-nesting. In the example above, the string would be parsed as \"text\"." } ;
11
12 HELP: /*
13 { $syntax "/* comment */" }
14 { $description "Provides C-like comments that can span multiple lines. One caveat is that " { $snippet "/*" } " and " { $snippet "*/" } " are still tokens and must not abut the comment text itself." }
15 { $example "USING: multiline ;"
16            "/* I think that I shall never see"
17            "   A poem lovely as a tree. */"
18            ""
19 } ;
20
21 HELP: HEREDOC:
22 { $syntax "HEREDOC: marker\n...text...marker" }
23 { $values { "marker" "a word (token)" } { "text" "arbitrary text" } { "" "a string" } }
24 { $description "A multiline string syntax with a user-specified terminating delimiter.  HEREDOC: reads the next word, and uses it as the 'close quote'.  All input from the beginning of the HEREDOC:'s next line, until the first appearance of the word's name, becomes a string.  The terminating word does not need to be at the beginning of a line.\n\nThe HEREDOC: line should not have anything after the delimiting word.  The delimiting word should be an alphanumeric token.  It should not be, as in some other languages, a \"quoted string\"." }
25 { $examples
26     { $example "USING: multiline prettyprint ;"
27                "HEREDOC: END\nx\nEND ."
28                "\"x\\n\""
29     }
30     { $example "USING: multiline prettyprint ;"
31                "HEREDOC: END\nxEND ."
32                "\"x\""
33     }
34     { $example "USING: multiline prettyprint sequences ;"
35                "2 5 HEREDOC: zap\nfoo\nbarzap subseq ."
36                "\"o\\nb\""
37     }
38 } ;
39
40 { POSTPONE: <" POSTPONE: STRING: } related-words
41
42 HELP: parse-multiline-string
43 { $values { "end-text" "a string delineating the end" } { "str" "the parsed string" } }
44 { $description "Parses the input stream until the " { $snippet "end-text" } " is reached and returns the parsed text as a string." }
45 { $notes "Used to implement " { $link POSTPONE: /* } " and " { $link POSTPONE: <" } "." } ;
46
47 ARTICLE: "multiline" "Multiline"
48 "Multiline strings:"
49 { $subsection POSTPONE: STRING: }
50 { $subsection POSTPONE: <" }
51 { $subsection POSTPONE: HEREDOC: }
52 "Multiline comments:"
53 { $subsection POSTPONE: /* }
54 "Writing new multiline parsing words:"
55 { $subsection parse-multiline-string }
56 ;
57
58 ABOUT: "multiline"