]> gitweb.factorcode.org Git - factor.git/blob - basis/peg/search/search-docs.factor
565601ea11facb93c200a8265e424fb53d31f7e9
[factor.git] / basis / peg / search / search-docs.factor
1 ! Copyright (C) 2006 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.syntax help.markup peg ;
4 IN: peg.search
5
6 HELP: tree-write
7 { $values
8   { "object" "an object" } }
9 { $description
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 "USE: peg.search" "{ 65 \"bc\" { 68 \"ef\" } } tree-write" "AbcDef" } ;
14
15 HELP: search
16 { $values
17   { "string" "a string" }
18   { "parser" "a peg based parser" }
19   { "seq"    "a sequence" }
20 }
21 { $description
22     "Returns a sequence containing the parse results of all substrings "
23     "from the input string that successfully parse using the "
24     "parser."
25 }
26
27 { $example "USING: peg.parsers peg.search prettyprint ;" "\"one 123 two 456\" 'integer' search ." "V{ 123 456 }" }
28 { $example "USING: peg peg.parsers peg.search prettyprint ;" "\"one 123 \\\"hello\\\" two 456\" 'integer' 'string' 2choice search ." "V{ 123 \"hello\" 456 }" }
29 { $see-also replace } ;
30
31 HELP: replace
32 { $values
33   { "string" "a string" }
34   { "parser" "a peg based parser" }
35   { "result"    "a string" }
36 }
37 { $description
38     "Returns a copy of the original string but with all substrings that "
39     "successfully parse with the given parser replaced with "
40     "the result of that parser."
41 }
42 { $example "USING: math math.parser peg peg.parsers peg.search prettyprint ;" "\"one 123 two 456\" 'integer' [ 2 * number>string ] action replace ." "\"one 246 two 912\"" }
43 { $see-also search } ;
44