factor/extra/parser-combinators/simple/simple-docs.factor

68 lines
3.1 KiB
Factor
Raw Normal View History

2007-09-20 18:09:08 -04:00
! Copyright (C) 2006 Chris Double.
! See http://factorcode.org/license.txt for BSD license.
USING: help.syntax help.markup parser-combinators ;
IN: parser-combinators.simple
2007-09-20 18:09:08 -04:00
2015-08-16 00:14:39 -04:00
HELP: digit-parser
{ $values
2007-09-20 18:09:08 -04:00
{ "parser" "a parser object" } }
{ $description
2007-09-20 18:09:08 -04:00
"Return a parser that consumes a single digit from "
"the input string. The numeric value of the digit "
" consumed is the result of the parse." }
{ $examples
2015-08-16 00:14:39 -04:00
{ $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"123\" digit-parser parse-1 ." "1" } } ;
2007-09-20 18:09:08 -04:00
2015-08-16 00:14:39 -04:00
HELP: integer-parser
{ $values
2007-09-20 18:09:08 -04:00
{ "parser" "a parser object" } }
{ $description
2007-09-20 18:09:08 -04:00
"Return a parser that consumes an integer from "
"the input string. The numeric value of the integer "
" consumed is the result of the parse." }
{ $examples
2015-08-16 00:14:39 -04:00
{ $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"123\" integer-parser parse-1 ." "123" } } ;
HELP: string-parser
{ $values
2007-09-20 18:09:08 -04:00
{ "parser" "a parser object" } }
{ $description
2007-09-20 18:09:08 -04:00
"Return a parser that consumes a string enclosed in "
"quotations from the input string. The string value "
" consumed is the result of the parse." }
{ $examples
2015-08-16 00:14:39 -04:00
{ $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"\\\"foo\\\"\" string-parser parse-1 ." "\"foo\"" } } ;
2008-03-11 20:51:58 -04:00
2015-08-16 00:14:39 -04:00
HELP: bold-parser
{ $values
2007-09-20 18:09:08 -04:00
{ "parser" "a parser object" } }
{ $description
2007-09-20 18:09:08 -04:00
"Return a parser that consumes a string enclosed in "
"the '*' character from the input string. This is "
"commonly used in markup languages to indicate bold "
"faced text." }
2015-08-16 00:14:39 -04:00
{ $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"*foo*\" bold-parser parse-1 ." "\"foo\"" }
{ $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"*foo*\" bold-parser [ \"<strong>\" \"</strong>\" surround ] <@ parse-1 ." "\"<strong>foo</strong>\"" } ;
2008-03-11 20:51:58 -04:00
2015-08-16 00:14:39 -04:00
HELP: italic-parser
{ $values
2007-09-20 18:09:08 -04:00
{ "parser" "a parser object" } }
{ $description
2007-09-20 18:09:08 -04:00
"Return a parser that consumes a string enclosed in "
"the '_' character from the input string. This is "
"commonly used in markup languages to indicate italic "
"faced text." }
{ $examples
2015-08-16 00:14:39 -04:00
{ $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"_foo_\" italic-parser parse-1 ." "\"foo\"" }
{ $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"_foo_\" italic-parser [ \"<emphasis>\" \"</emphasis>\" surround ] <@ parse-1 ." "\"<emphasis>foo</emphasis>\"" } } ;
2007-09-20 18:09:08 -04:00
HELP: comma-list
{ $values
2007-09-20 18:09:08 -04:00
{ "element" "a parser object" } { "parser" "a parser object" } }
{ $description
2007-09-20 18:09:08 -04:00
"Return a parser that parses comma separated lists of elements. "
2015-08-16 00:14:39 -04:00
{ $snippet "element-parser" } " should be a parser that can parse the elements. The "
2007-09-20 18:09:08 -04:00
"result of the parser is a sequence of the parsed elements." }
{ $examples
2015-08-16 00:14:39 -04:00
{ $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"1,2,3,4\" integer-parser comma-list parse-1 ." "{ 1 2 3 4 }" } } ;
2015-08-16 00:14:39 -04:00
{ $see-also digit-parser integer-parser string-parser bold-parser italic-parser comma-list } related-words