diff --git a/basis/http/client/client.factor b/basis/http/client/client.factor index 9260f15a7b..119fa23567 100644 --- a/basis/http/client/client.factor +++ b/basis/http/client/client.factor @@ -3,14 +3,14 @@ USING: accessors assocs kernel math math.parser namespaces make sequences io io.sockets io.streams.string io.files io.timeouts strings splitting calendar continuations accessors vectors -math.order hashtables byte-arrays prettyprint destructors +math.order hashtables byte-arrays destructors io.encodings io.encodings.string io.encodings.ascii io.encodings.8-bit io.encodings.binary io.streams.duplex -fry debugger summary ascii urls urls.encoding present +fry ascii urls urls.encoding present http http.parsers ; IN: http.client @@ -84,10 +84,6 @@ M: f >post-data ; ERROR: too-many-redirects ; -M: too-many-redirects summary - drop - [ "Redirection limit of " % max-redirects # " exceeded" % ] "" make ; - ERROR: download-failed response ; -M: download-failed error. - "HTTP request failed:" print nl - response>> . ; - : check-response ( response -- response ) dup code>> success? [ download-failed ] unless ; @@ -203,3 +195,7 @@ M: download-failed error. : http-post ( post-data url -- response data ) http-request ; + +USING: vocabs vocabs.loader ; + +"debugger" vocab [ "http.client.debugger" require ] when diff --git a/basis/http/client/debugger/debugger.factor b/basis/http/client/debugger/debugger.factor new file mode 100644 index 0000000000..413ae7bd85 --- /dev/null +++ b/basis/http/client/debugger/debugger.factor @@ -0,0 +1,13 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel summary debugger io make math.parser +prettyprint http.client accessors ; +IN: http.client.debugger + +M: too-many-redirects summary + drop + [ "Redirection limit of " % max-redirects # " exceeded" % ] "" make ; + +M: download-failed error. + "HTTP request failed:" print nl + response>> . ; diff --git a/basis/http/http.factor b/basis/http/http.factor index d006c86462..bbb0335ae4 100644 --- a/basis/http/http.factor +++ b/basis/http/http.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2003, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel combinators math namespaces make -assocs sequences splitting sorting sets debugger -strings vectors hashtables quotations arrays byte-arrays -math.parser calendar calendar.format present urls +USING: accessors kernel combinators math namespaces make assocs +sequences splitting sorting sets strings vectors hashtables +quotations arrays byte-arrays math.parser calendar +calendar.format present urls io io.encodings io.encodings.iana io.encodings.binary io.encodings.8-bit diff --git a/basis/peg/debugger/debugger.factor b/basis/peg/debugger/debugger.factor new file mode 100644 index 0000000000..7e751b5110 --- /dev/null +++ b/basis/peg/debugger/debugger.factor @@ -0,0 +1,12 @@ +USING: io kernel accessors math.parser sequences prettyprint +debugger peg ; +IN: peg.debugger + +M: parse-error error. + "Peg parsing error at character position " write dup position>> number>string write + "." print "Expected " write messages>> [ " or " write ] [ write ] interleave nl ; + +M: parse-failed error. + "The " write dup word>> pprint " word could not parse the following input:" print nl + input>> . ; + diff --git a/basis/peg/ebnf/ebnf.factor b/basis/peg/ebnf/ebnf.factor index ccae0fec93..ca97886235 100644 --- a/basis/peg/ebnf/ebnf.factor +++ b/basis/peg/ebnf/ebnf.factor @@ -5,7 +5,7 @@ sequences quotations vectors namespaces make math assocs continuations peg peg.parsers unicode.categories multiline splitting accessors effects sequences.deep peg.search combinators.short-circuit lexer io.streams.string stack-checker -io prettyprint combinators parser ; +io combinators parser ; IN: peg.ebnf : rule ( name word -- parser ) @@ -458,16 +458,13 @@ M: ebnf-var build-locals ( code ast -- ) M: object build-locals ( code ast -- ) drop ; +ERROR: bad-effect quot effect ; + : check-action-effect ( quot -- quot ) dup infer { { [ dup (( a -- b )) effect<= ] [ drop ] } { [ dup (( -- b )) effect<= ] [ drop [ drop ] prepose ] } - [ - [ - "Bad effect: " write effect>string write - " for quotation " write pprint - ] with-string-writer throw - ] + [ bad-effect ] } cond ; M: ebnf-action (transform) ( ast -- parser ) diff --git a/basis/peg/peg.factor b/basis/peg/peg.factor index 8a62365f53..3fc6fec8ed 100644 --- a/basis/peg/peg.factor +++ b/basis/peg/peg.factor @@ -1,14 +1,12 @@ ! Copyright (C) 2007, 2008 Chris Double. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences strings fry namespaces make math assocs -debugger io vectors arrays math.parser math.order -vectors combinators classes sets unicode.categories -compiler.units parser words quotations effects memoize accessors -locals effects splitting combinators.short-circuit generalizations ; +io vectors arrays math.parser math.order vectors combinators +classes sets unicode.categories compiler.units parser words +quotations effects memoize accessors locals effects splitting +combinators.short-circuit generalizations ; IN: peg -USE: prettyprint - TUPLE: parse-result remaining ast ; TUPLE: parse-error position messages ; TUPLE: parser peg compiled id ; @@ -19,10 +17,6 @@ M: parser hashcode* id>> hashcode* ; C: parse-result C: parse-error -M: parse-error error. - "Peg parsing error at character position " write dup position>> number>string write - "." print "Expected " write messages>> [ " or " write ] [ write ] interleave nl ; - SYMBOL: error-stack : (merge-errors) ( a b -- c ) @@ -238,8 +232,6 @@ TUPLE: peg-head rule-id involved-set eval-set ; nip ] if ; -USE: prettyprint - : apply-rule ( r p -- ast ) ! 2dup [ rule-id ] dip 2array "apply-rule: " write . 2dup recall [ @@ -624,10 +616,6 @@ PRIVATE> ERROR: parse-failed input word ; -M: parse-failed error. - "The " write dup word>> pprint " word could not parse the following input:" print nl - input>> . ; - : PEG: (:) [let | def [ ] word [ ] | @@ -643,3 +631,9 @@ M: parse-failed error. ] with-compilation-unit ] over push-all ] ; parsing + +USING: vocabs vocabs.loader ; + +"debugger" vocab [ + "peg.debugger" require +] when diff --git a/basis/urls/prettyprint/prettyprint.factor b/basis/urls/prettyprint/prettyprint.factor new file mode 100644 index 0000000000..59fb79e8d3 --- /dev/null +++ b/basis/urls/prettyprint/prettyprint.factor @@ -0,0 +1,6 @@ +! Copyright (C) 2008 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: kernel present prettyprint.custom prettyprint.backend urls ; +IN: urls.prettyprint + +M: url pprint* dup present "URL\" " "\"" pprint-string ; diff --git a/basis/urls/urls.factor b/basis/urls/urls.factor index 5f6d04a54f..d71ce4ef7b 100644 --- a/basis/urls/urls.factor +++ b/basis/urls/urls.factor @@ -4,8 +4,7 @@ USING: kernel ascii combinators combinators.short-circuit sequences splitting fry namespaces make assocs arrays strings io.sockets io.encodings.string io.encodings.utf8 math math.parser accessors parser strings.parser lexer -prettyprint.backend prettyprint.custom hashtables present -peg.ebnf urls.encoding ; +hashtables present peg.ebnf urls.encoding ; IN: urls TUPLE: url protocol username password host port path query anchor ; @@ -182,4 +181,8 @@ PRIVATE> ! Literal syntax : URL" lexer get skip-blank parse-string >url parsed ; parsing -M: url pprint* dup present "URL\" " "\"" pprint-string ; +USING: vocabs vocabs.loader ; + +"prettyprint" vocab [ + "urls.prettyprint" require +] when