Merge branch 'master' of factorcode.org:/git/factor
						commit
						cfcc447652
					
				|  | @ -11,7 +11,7 @@ HELP: 1token | ||||||
| } { $description | } { $description | ||||||
|     "Calls 1string on a character and returns a parser that matches that character." |     "Calls 1string on a character and returns a parser that matches that character." | ||||||
| } { $examples | } { $examples | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"a\" CHAR: a 1token parse parse-result-ast ." "\"a\"" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"a\" CHAR: a 1token parse ." "\"a\"" } | ||||||
| } { $see-also 'string' } ; | } { $see-also 'string' } ; | ||||||
| 
 | 
 | ||||||
| HELP: (list-of) | HELP: (list-of) | ||||||
|  | @ -33,8 +33,8 @@ HELP: list-of | ||||||
|     "Returns a parser that returns a list of items separated by the separator parser.  Hides the separators and matches a list of one or more items." |     "Returns a parser that returns a list of items separated by the separator parser.  Hides the separators and matches a list of one or more items." | ||||||
| } { $notes "Use " { $link list-of-many } " to ensure a list contains two or more items." } | } { $notes "Use " { $link list-of-many } " to ensure a list contains two or more items." } | ||||||
| { $examples | { $examples | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"a\" \"a\" token \",\" token list-of parse parse-result-ast ." "V{ \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"a\" \"a\" token \",\" token list-of parse  ." "V{ \"a\" }" } | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"a,a,a,a\" \"a\" token \",\" token list-of parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"a,a,a,a\" \"a\" token \",\" token list-of parse ." "V{ \"a\" \"a\" \"a\" \"a\" }" } | ||||||
| } { $see-also list-of-many } ; | } { $see-also list-of-many } ; | ||||||
|      |      | ||||||
| HELP: list-of-many | HELP: list-of-many | ||||||
|  | @ -46,8 +46,8 @@ HELP: list-of-many | ||||||
|     "Returns a parser that returns a list of items separated by the separator parser.  Hides the separators and matches a list of two or more items." |     "Returns a parser that returns a list of items separated by the separator parser.  Hides the separators and matches a list of two or more items." | ||||||
| } { $notes "Use " { $link list-of } " to return a list of only one item." | } { $notes "Use " { $link list-of } " to return a list of only one item." | ||||||
| } { $examples | } { $examples | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"a\" \"a\" token \",\" token list-of-many parse ." "f" } |     { $code "USING: peg peg.parsers prettyprint ;" "\"a\" \"a\" token \",\" token list-of-many parse => exception" } | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"a,a,a,a\" \"a\" token \",\" token list-of-many parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"a,a,a,a\" \"a\" token \",\" token list-of-many parse ." "V{ \"a\" \"a\" \"a\" \"a\" }" } | ||||||
| } { $see-also list-of } ; | } { $see-also list-of } ; | ||||||
| 
 | 
 | ||||||
| HELP: epsilon | HELP: epsilon | ||||||
|  | @ -72,8 +72,8 @@ HELP: exactly-n | ||||||
| } { $description | } { $description | ||||||
|     "Returns a parser that matches an exact repetition of the input parser." |     "Returns a parser that matches an exact repetition of the input parser." | ||||||
| } { $examples | } { $examples | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 4 exactly-n parse ." "f" } |     { $code "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 4 exactly-n parse => exception" } | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 4 exactly-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 4 exactly-n parse ." "V{ \"a\" \"a\" \"a\" \"a\" }" } | ||||||
| } { $see-also at-least-n at-most-n from-m-to-n } ; | } { $see-also at-least-n at-most-n from-m-to-n } ; | ||||||
| 
 | 
 | ||||||
| HELP: at-least-n | HELP: at-least-n | ||||||
|  | @ -84,9 +84,9 @@ HELP: at-least-n | ||||||
| } { $description | } { $description | ||||||
|     "Returns a parser that matches n or more repetitions of the input parser." |     "Returns a parser that matches n or more repetitions of the input parser." | ||||||
| } { $examples | } { $examples | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 4 at-least-n parse ." "f" } |     { $code "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 4 at-least-n parse => exception"} | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 4 at-least-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 4 at-least-n parse ." "V{ \"a\" \"a\" \"a\" \"a\" }" } | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaaa\" \"a\" token 4 at-least-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaaa\" \"a\" token 4 at-least-n parse ." "V{ \"a\" \"a\" \"a\" \"a\" \"a\" }" } | ||||||
| } { $see-also exactly-n at-most-n from-m-to-n } ; | } { $see-also exactly-n at-most-n from-m-to-n } ; | ||||||
| 
 | 
 | ||||||
| HELP: at-most-n | HELP: at-most-n | ||||||
|  | @ -97,8 +97,8 @@ HELP: at-most-n | ||||||
| } { $description | } { $description | ||||||
|     "Returns a parser that matches n or fewer repetitions of the input parser." |     "Returns a parser that matches n or fewer repetitions of the input parser." | ||||||
| } { $examples | } { $examples | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 4 at-most-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 4 at-most-n parse ." "V{ \"a\" \"a\" \"a\" \"a\" }" } | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaaa\" \"a\" token 4 at-most-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaaa\" \"a\" token 4 at-most-n parse ." "V{ \"a\" \"a\" \"a\" \"a\" }" } | ||||||
| } { $see-also exactly-n at-least-n from-m-to-n } ; | } { $see-also exactly-n at-least-n from-m-to-n } ; | ||||||
| 
 | 
 | ||||||
| HELP: from-m-to-n | HELP: from-m-to-n | ||||||
|  | @ -110,9 +110,9 @@ HELP: from-m-to-n | ||||||
| } { $description | } { $description | ||||||
|     "Returns a parser that matches between and including m to n repetitions of the input parser." |     "Returns a parser that matches between and including m to n repetitions of the input parser." | ||||||
| } { $examples | } { $examples | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 3 4 from-m-to-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"aaa\" \"a\" token 3 4 from-m-to-n parse ." "V{ \"a\" \"a\" \"a\" }" } | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 3 4 from-m-to-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaa\" \"a\" token 3 4 from-m-to-n parse ." "V{ \"a\" \"a\" \"a\" \"a\" }" } | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaaa\" \"a\" token 3 4 from-m-to-n parse parse-result-ast ." "V{ \"a\" \"a\" \"a\" \"a\" }" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"aaaaa\" \"a\" token 3 4 from-m-to-n parse ." "V{ \"a\" \"a\" \"a\" \"a\" }" } | ||||||
| } { $see-also exactly-n at-most-n at-least-n } ; | } { $see-also exactly-n at-most-n at-least-n } ; | ||||||
| 
 | 
 | ||||||
| HELP: pack | HELP: pack | ||||||
|  | @ -124,7 +124,7 @@ HELP: pack | ||||||
| } { $description | } { $description | ||||||
|     "Returns a parser that parses the begin, body, and end parsers in order.  The begin and end parsers are hidden." |     "Returns a parser that parses the begin, body, and end parsers in order.  The begin and end parsers are hidden." | ||||||
| } { $examples | } { $examples | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"hi123bye\" \"hi\" token 'integer' \"bye\" token pack parse parse-result-ast ." "123" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"hi123bye\" \"hi\" token 'integer' \"bye\" token pack parse ." "123" } | ||||||
| } { $see-also surrounded-by } ; | } { $see-also surrounded-by } ; | ||||||
| 
 | 
 | ||||||
| HELP: surrounded-by | HELP: surrounded-by | ||||||
|  | @ -136,7 +136,7 @@ HELP: surrounded-by | ||||||
| } { $description | } { $description | ||||||
|     "Calls token on begin and end to make them into string parsers.  Returns a parser that parses the begin, body, and end parsers in order.  The begin and end parsers are hidden." |     "Calls token on begin and end to make them into string parsers.  Returns a parser that parses the begin, body, and end parsers in order.  The begin and end parsers are hidden." | ||||||
| } { $examples | } { $examples | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;" "\"hi123bye\" 'integer' \"hi\" \"bye\" surrounded-by parse parse-result-ast ." "123" } |     { $example "USING: peg peg.parsers prettyprint ;" "\"hi123bye\" 'integer' \"hi\" \"bye\" surrounded-by parse ." "123" } | ||||||
| } { $see-also pack } ; | } { $see-also pack } ; | ||||||
| 
 | 
 | ||||||
| HELP: 'digit' | HELP: 'digit' | ||||||
|  | @ -173,7 +173,7 @@ HELP: range-pattern | ||||||
| "of characters separated with a dash (-) represents the " | "of characters separated with a dash (-) represents the " | ||||||
| "range of characters from the first to the second, inclusive." | "range of characters from the first to the second, inclusive." | ||||||
| { $examples | { $examples | ||||||
|     { $example "USING: peg peg.parsers prettyprint strings ;" "\"a\" \"_a-zA-Z\" range-pattern parse parse-result-ast 1string ." "\"a\"" }  |     { $example "USING: peg peg.parsers prettyprint strings ;" "\"a\" \"_a-zA-Z\" range-pattern parse 1string ." "\"a\"" }  | ||||||
|     { $example "USING: peg peg.parsers prettyprint ;\n\"0\" \"^0-9\" range-pattern parse ." "f" }  |     { $code "USING: peg peg.parsers prettyprint ;\n\"0\" \"^0-9\" range-pattern parse => exception"}  | ||||||
| } | } | ||||||
| }  ; | }  ; | ||||||
|  |  | ||||||
|  | @ -7,11 +7,11 @@ HELP: parse | ||||||
| { $values  | { $values  | ||||||
|   { "input" "a string" }  |   { "input" "a string" }  | ||||||
|   { "parser" "a parser" }  |   { "parser" "a parser" }  | ||||||
|   { "result" "a parse-result or f" }  |   { "ast" "an object" }  | ||||||
| } | } | ||||||
| { $description  | { $description  | ||||||
|     "Given the input string, parse it using the given parser. The result is a <parse-result> object if " |     "Given the input string, parse it using the given parser. The result is the abstract " | ||||||
|     "the parse was successful, otherwise it is f." }  |     "syntax tree returned by the parser." }  | ||||||
| { $see-also compile } ; | { $see-also compile } ; | ||||||
| 
 | 
 | ||||||
| HELP: compile | HELP: compile | ||||||
|  | @ -20,7 +20,7 @@ HELP: compile | ||||||
|   { "word" "a word" }  |   { "word" "a word" }  | ||||||
| } | } | ||||||
| { $description  | { $description  | ||||||
|     "Compile the parser to a word. The word will have stack effect ( -- result )." |     "Compile the parser to a word. The word will have stack effect ( -- ast )." | ||||||
| }  | }  | ||||||
| { $see-also parse } ; | { $see-also parse } ; | ||||||
| 
 | 
 | ||||||
|  | @ -104,8 +104,7 @@ HELP: semantic | ||||||
|     "Returns a parser that succeeds if the 'p1' parser succeeds and the quotation called with " |     "Returns a parser that succeeds if the 'p1' parser succeeds and the quotation called with " | ||||||
|     "the AST produced by 'p1' on the stack returns true." } |     "the AST produced by 'p1' on the stack returns true." } | ||||||
| { $examples  | { $examples  | ||||||
|   { $example "USING: kernel math peg prettyprint ;" "\"A\" [ drop t ] satisfy [ 66 > ] semantic parse ." "f" }  |   { $example "USING: kernel math peg prettyprint ;" "\"C\" [ drop t ] satisfy [ 66 > ] semantic parse ." "67" }  | ||||||
|   { $example "USING: kernel math peg prettyprint ;" "\"C\" [ drop t ] satisfy [ 66 > ] semantic parse parse-result-ast ." "67" }  |  | ||||||
| } ; | } ; | ||||||
| 
 | 
 | ||||||
| HELP: ensure | HELP: ensure | ||||||
|  |  | ||||||
|  | @ -31,7 +31,7 @@ TUPLE: listener-gadget < track input output stack ; | ||||||
| 
 | 
 | ||||||
| : welcome. ( -- ) | : welcome. ( -- ) | ||||||
|    "If this is your first time with Factor, please read the " print |    "If this is your first time with Factor, please read the " print | ||||||
|    "cookbook" ($link) "." print nl ; |    "handbook" ($link) "." print nl ; | ||||||
| 
 | 
 | ||||||
| M: listener-gadget focusable-child* | M: listener-gadget focusable-child* | ||||||
|     input>> ; |     input>> ; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue