]> gitweb.factorcode.org Git - factor.git/blob - extra/parser-combinators/simple/simple-docs.factor
84f40f45c5d1742fde826c15412ff9f6f0abae08
[factor.git] / extra / parser-combinators / simple / simple-docs.factor
1 ! Copyright (C) 2006 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.syntax help.markup parser-combinators ;
4 IN: parser-combinators.simple
5
6 HELP: digit-parser
7 { $values
8   { "parser" "a parser object" } }
9 { $description
10     "Return a parser that consumes a single digit from "
11     "the input string. The numeric value of the digit "
12     " consumed is the result of the parse." }
13 { $examples
14 { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"123\" digit-parser parse-1 ." "1" } } ;
15
16 HELP: integer-parser
17 { $values
18   { "parser" "a parser object" } }
19 { $description
20     "Return a parser that consumes an integer from "
21     "the input string. The numeric value of the integer "
22     " consumed is the result of the parse." }
23 { $examples
24 { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"123\" integer-parser parse-1 ." "123" } } ;
25 HELP: string-parser
26 { $values
27   { "parser" "a parser object" } }
28 { $description
29     "Return a parser that consumes a string enclosed in "
30     "quotations from the input string. The string value "
31     " consumed is the result of the parse." }
32 { $examples
33 { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"\\\"foo\\\"\" string-parser parse-1 ." "\"foo\"" } } ;
34
35 HELP: bold-parser
36 { $values
37   { "parser" "a parser object" } }
38 { $description
39     "Return a parser that consumes a string enclosed in "
40     "the '*' character from the input string. This is "
41     "commonly used in markup languages to indicate bold "
42     "faced text." }
43 { $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"*foo*\" bold-parser parse-1 ." "\"foo\"" }
44 { $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"*foo*\" bold-parser [ \"<strong>\" \"</strong>\" surround ] <@ parse-1 ." "\"<strong>foo</strong>\"" } ;
45
46 HELP: italic-parser
47 { $values
48   { "parser" "a parser object" } }
49 { $description
50     "Return a parser that consumes a string enclosed in "
51     "the '_' character from the input string. This is "
52     "commonly used in markup languages to indicate italic "
53     "faced text." }
54 { $examples
55 { $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"_foo_\" italic-parser parse-1 ." "\"foo\"" }
56 { $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"_foo_\" italic-parser [ \"<emphasis>\" \"</emphasis>\" surround ] <@ parse-1 ." "\"<emphasis>foo</emphasis>\"" } } ;
57 HELP: comma-list
58 { $values
59   { "element" "a parser object" } { "parser" "a parser object" } }
60 { $description
61     "Return a parser that parses comma separated lists of elements. "
62     { $snippet "element-parser" } " should be a parser that can parse the elements. The "
63     "result of the parser is a sequence of the parsed elements." }
64 { $examples
65 { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"1,2,3,4\" integer-parser comma-list parse-1 ." "{ 1 2 3 4 }" } } ;
66
67 { $see-also digit-parser integer-parser string-parser bold-parser italic-parser comma-list } related-words