diff --git a/extra/fjsc/fjsc.factor b/extra/fjsc/fjsc.factor index 5f1f977d20..e12092603a 100755 --- a/extra/fjsc/fjsc.factor +++ b/extra/fjsc/fjsc.factor @@ -353,11 +353,11 @@ M: quotation fjsc-parse ( object -- ast ) ] with-string-writer ; : fjsc-compile* ( string -- string ) - 'statement' parse parse-result-ast fjsc-compile ; + 'statement' parse ast>> fjsc-compile ; : fc* ( string -- string ) [ - 'statement' parse parse-result-ast values>> do-expressions + 'statement' parse ast>> values>> do-expressions ] { } make [ write ] each ; diff --git a/extra/json/reader/reader.factor b/extra/json/reader/reader.factor index 6bd6905804..e21b1292e3 100755 --- a/extra/json/reader/reader.factor +++ b/extra/json/reader/reader.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: kernel parser-combinators namespaces sequences promises strings assocs math math.parser math.vectors math.functions math.order - lists hashtables ascii ; + lists hashtables ascii accessors ; IN: json.reader ! Grammar for JSON from RFC 4627 @@ -169,11 +169,12 @@ LAZY: 'value' ( -- parser ) 'array' , 'number' , ] [<|>] spaced ; +ERROR: could-not-parse-json ; : json> ( string -- object ) #! Parse a json formatted string to a factor object 'value' parse dup nil? [ - "Could not parse json" throw + could-not-parse-json ] [ - car parse-result-parsed + car parsed>> ] if ; diff --git a/extra/parser-combinators/parser-combinators.factor b/extra/parser-combinators/parser-combinators.factor index 2414c1ced3..a05c140b86 100755 --- a/extra/parser-combinators/parser-combinators.factor +++ b/extra/parser-combinators/parser-combinators.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: lists lists.lazy promises kernel sequences strings math arrays splitting quotations combinators namespaces -unicode.case unicode.categories sequences.deep ; +unicode.case unicode.categories sequences.deep accessors ; IN: parser-combinators ! Parser combinator protocol @@ -13,11 +13,13 @@ M: promise parse ( input parser -- list ) TUPLE: parse-result parsed unparsed ; +ERROR: cannot-parse input ; + : parse-1 ( input parser -- result ) dupd parse dup nil? [ - "Cannot parse " rot append throw + rot cannot-parse ] [ - nip car parse-result-parsed + nip car parsed>> ] if ; C: parse-result @@ -26,12 +28,12 @@ C: parse-result 1list ; : parse-result-parsed-slice ( parse-result -- slice ) - dup parse-result-parsed empty? [ - parse-result-unparsed 0 0 rot + dup parsed>> empty? [ + unparsed>> 0 0 rot ] [ - dup parse-result-unparsed - dup slice-from [ rot parse-result-parsed length - ] keep - rot slice-seq + dup unparsed>> + dup from>> [ rot parsed>> length - ] keep + rot seq>> ] if ; : string= ( str1 str2 ignore-case -- ? ) @@ -132,7 +134,7 @@ TUPLE: and-parser parsers ; : <&> ( parser1 parser2 -- parser ) over and-parser? [ - >r and-parser-parsers r> suffix + >r parsers>> r> suffix ] [ 2array ] if and-parser boa ; @@ -142,11 +144,11 @@ TUPLE: and-parser parsers ; : and-parser-parse ( list p1 -- list ) swap [ - dup parse-result-unparsed rot parse + dup unparsed>> rot parse [ - >r parse-result-parsed r> - [ parse-result-parsed 2array ] keep - parse-result-unparsed + >r parsed>> r> + [ parsed>> 2array ] keep + unparsed>> ] lazy-map-with ] lazy-map-with lconcat ; diff --git a/extra/peg/ebnf/ebnf.factor b/extra/peg/ebnf/ebnf.factor index 9ca8f470bb..6e9d78e649 100644 --- a/extra/peg/ebnf/ebnf.factor +++ b/extra/peg/ebnf/ebnf.factor @@ -508,10 +508,10 @@ M: ebnf-non-terminal (transform) ( ast -- parser ) : check-parse-result ( result -- result ) dup [ - dup parse-result-remaining [ blank? ] trim empty? [ + dup remaining>> [ blank? ] trim empty? [ [ "Unable to fully parse EBNF. Left to parse was: " % - parse-result-remaining % + remaining>> % ] "" make throw ] unless ] [