]> gitweb.factorcode.org Git - factor.git/blob - extra/parser-combinators/simple/simple-docs.factor
Factor source files should not be executable
[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'
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' parse-1 ." "1" } } ;
15
16 HELP: 'integer'
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' parse-1 ." "123" } } ;
25 HELP: 'string'
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' parse-1 ." "\"foo\"" } } ;
34
35 HELP: 'bold'
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' parse-1 ." "\"foo\"" }
44 { $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"*foo*\" 'bold' [ \"<strong>\" \"</strong>\" surround ] <@ parse-1 ." "\"<strong>foo</strong>\"" } ;
45
46 HELP: 'italic'
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' parse-1 ." "\"foo\"" }
56 { $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"_foo_\" 'italic' [ \"<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     "'element' 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' comma-list parse-1 ." "{ 1 2 3 4 }" } } ;
66
67 { $see-also 'digit' 'integer' 'string' 'bold' 'italic' comma-list } related-words