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 parser-combinators.replace ;
8 { "object" "an object" } }
10 "Write the object to the standard output stream, unless "
11 "it is an array, in which case recurse through the array "
12 "writing each object to the stream." }
13 { $example "[ { 65 \"bc\" { 68 \"ef\" } } tree-write ] string-out ." "\"AbcDef\"" } ;
17 { "string" "a string" }
18 { "parser" "a parser combinator based parser" }
19 { "seq" "a sequence" }
22 "Returns a sequence containing the parse results of all substrings "
23 "from the input string that successfully parse using the "
27 { $example "\"one 123 two 456\" 'integer' search ." "{ 123 456 }" }
28 { $example "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' <|> search ." "{ 123 \"hello\" 456 }" }
29 { $see-also search* replace replace* } ;
33 { "string" "a string" }
34 { "parsers" "a sequence of parser combinator based parsers" }
35 { "seq" "a sequence" }
38 "Returns a sequence containing the parse results of all substrings "
39 "from the input string that successfully parse using any of the "
40 "parsers in the 'parsers' sequence."
43 { $example "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' 2array search* ." "{ 123 \"hello\" 456 }" }
44 { $see-also search replace replace* } ;
48 { "string" "a string" }
49 { "parser" "a parser combinator based parser" }
50 { "result" "a string" }
53 "Returns a copy of the original string but with all substrings that "
54 "successfully parse with the given parser replaced with "
55 "the result of that parser."
57 { $example "\"one 123 two 456\" 'integer' [ 2 * number>string ] <@ replace ." "\"one 246 two 912\"" }
58 { $example "\"hello *world* from *factor*\" 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@ replace ." "\"hello <strong>world</strong> from <strong>factor</strong>\"" }
59 { $example "\"hello *world* from _factor_\"\n 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@\n 'italic' [ \"<emphasis>\" swap \"</emphasis>\" 3append ] <@ <|>\n replace ." "\"hello <strong>world</strong> from <emphasis>factor</emphasis>\"" }
60 { $see-also search search* replace* } ;
64 { "string" "a string" }
65 { "parsers" "a sequence of parser combinator based parsers" }
66 { "result" "a string" }
69 "Returns a copy of the original string but with all substrings that "
70 "successfully parse with the given parsers replaced with "
71 "the result of that parser. Each parser is done in sequence so that "
72 "the parse results of the first parser can be replaced by later parsers."
74 { $example "\"*hello _world_*\"\n 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@\n 'italic' [ \"<emphasis>\" swap \"</emphasis>\" 3append ] <@ 2array\n replace* ." "\"<strong>hello <emphasis>world</emphasis></strong>\"" }
75 { $see-also search search* replace* } ;