| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ! Copyright (C) 2006 Chris Double. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2008-01-14 16:42:21 -05:00
										 |  |  | USING: help.syntax help.markup parser-combinators ;
 | 
					
						
							|  |  |  | IN: parser-combinators.simple | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | HELP: 'digit' | 
					
						
							|  |  |  | { $values  | 
					
						
							|  |  |  |   { "parser" "a parser object" } } | 
					
						
							|  |  |  | { $description  | 
					
						
							|  |  |  |     "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 | 
					
						
							| 
									
										
										
										
											2008-06-03 05:06:52 -04:00
										 |  |  | { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"123\" 'digit' parse-1 ." "1" } } ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | HELP: 'integer' | 
					
						
							|  |  |  | { $values  | 
					
						
							|  |  |  |   { "parser" "a parser object" } } | 
					
						
							|  |  |  | { $description  | 
					
						
							|  |  |  |     "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 | 
					
						
							| 
									
										
										
										
											2008-06-03 05:06:52 -04:00
										 |  |  | { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"123\" 'integer' parse-1 ." "123" } } ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | HELP: 'string' | 
					
						
							|  |  |  | { $values  | 
					
						
							|  |  |  |   { "parser" "a parser object" } } | 
					
						
							|  |  |  | { $description  | 
					
						
							|  |  |  |     "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 | 
					
						
							| 
									
										
										
										
											2008-06-03 05:06:52 -04:00
										 |  |  | { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"\\\"foo\\\"\" 'string' parse-1 ." "\"foo\"" } } ;
 | 
					
						
							| 
									
										
										
										
											2008-03-11 20:51:58 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | HELP: 'bold' | 
					
						
							|  |  |  | { $values  | 
					
						
							|  |  |  |   { "parser" "a parser object" } } | 
					
						
							|  |  |  | { $description  | 
					
						
							|  |  |  |     "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." } | 
					
						
							| 
									
										
										
										
											2008-03-11 20:51:58 -04:00
										 |  |  | { $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"*foo*\" 'bold' parse-1 ." "\"foo\"" } | 
					
						
							|  |  |  | { $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"*foo*\" 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@ parse-1 ." "\"<strong>foo</strong>\"" } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | HELP: 'italic' | 
					
						
							|  |  |  | { $values  | 
					
						
							|  |  |  |   { "parser" "a parser object" } } | 
					
						
							|  |  |  | { $description  | 
					
						
							|  |  |  |     "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 | 
					
						
							| 
									
										
										
										
											2008-03-11 20:51:58 -04:00
										 |  |  | { $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"_foo_\" 'italic' parse-1 ." "\"foo\"" } | 
					
						
							|  |  |  | { $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"_foo_\" 'italic' [ \"<emphasis>\" swap \"</emphasis>\" 3append ] <@ parse-1 ." "\"<emphasis>foo</emphasis>\"" } } ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | HELP: comma-list | 
					
						
							|  |  |  | { $values  | 
					
						
							|  |  |  |   { "element" "a parser object" } { "parser" "a parser object" } } | 
					
						
							|  |  |  | { $description  | 
					
						
							|  |  |  |     "Return a parser that parses comma separated lists of elements. " | 
					
						
							|  |  |  |     "'element' should be a parser that can parse the elements. The " | 
					
						
							|  |  |  |     "result of the parser is a sequence of the parsed elements." } | 
					
						
							|  |  |  | { $examples | 
					
						
							| 
									
										
										
										
											2008-06-03 05:06:52 -04:00
										 |  |  | { $example "USING: lists.lazy parser-combinators parser-combinators.simple prettyprint ;" "\"1,2,3,4\" 'integer' comma-list parse-1 ." "{ 1 2 3 4 }" } } ;
 | 
					
						
							| 
									
										
										
										
											2007-11-24 18:07:01 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | { $see-also 'digit' 'integer' 'string' 'bold' 'italic' comma-list } related-words |