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
8 { "parser" "a parser object" } }
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." }
14 { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"123\" 'digit' parse-1 ." "1" } } ;
18 { "parser" "a parser object" } }
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." }
24 { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"123\" 'integer' parse-1 ." "123" } } ;
27 { "parser" "a parser object" } }
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." }
33 { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"\\\"foo\\\"\" 'string' parse-1 ." "\"foo\"" } } ;
37 { "parser" "a parser object" } }
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 "
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>\"" } ;
48 { "parser" "a parser object" } }
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 "
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>\"" } } ;
59 { "element" "a parser object" } { "parser" "a parser object" } }
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." }
65 { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"1,2,3,4\" 'integer' comma-list parse-1 ." "{ 1 2 3 4 }" } } ;
67 { $see-also 'digit' 'integer' 'string' 'bold' 'italic' comma-list } related-words