From 1a32ffafa389a9769e7d96ce1f7e599247fef280 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Tue, 8 Jul 2008 22:58:34 -0500 Subject: [PATCH 1/3] bake: work with strings --- extra/bake/bake.factor | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extra/bake/bake.factor b/extra/bake/bake.factor index 4ce7bfb586..bcb7c2238f 100644 --- a/extra/bake/bake.factor +++ b/extra/bake/bake.factor @@ -1,6 +1,6 @@ USING: kernel parser namespaces sequences quotations arrays vectors splitting - words math + strings words math macros arrays.lib combinators.lib combinators.conditional newfx ; IN: bake @@ -20,7 +20,9 @@ DEFER: [bake] : broil-element ( obj -- quot ) { { [ comma? ] [ drop [ >r ] ] } + { [ f = ] [ [ >r ] prefix-on ] } { [ integer? ] [ [ >r ] prefix-on ] } + { [ string? ] [ [ >r ] prefix-on ] } { [ sequence? ] [ [bake] [ >r ] append ] } { [ word? ] [ literalize [ >r ] prefix-on ] } { [ drop t ] [ [ >r ] prefix-on ] } From 2c8866c1394621df946af41da99e8802a1c89632 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Tue, 8 Jul 2008 23:08:12 -0500 Subject: [PATCH 2/3] documents: move from delegation to inheritance --- extra/documents/documents.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extra/documents/documents.factor b/extra/documents/documents.factor index 9e4802c2ef..d046102ec9 100755 --- a/extra/documents/documents.factor +++ b/extra/documents/documents.factor @@ -15,11 +15,11 @@ IN: documents : lines-equal? ( loc1 loc2 -- ? ) [ first ] bi@ number= ; -TUPLE: document locs ; +TUPLE: document < model locs ; : ( -- document ) - V{ "" } clone V{ } clone - { set-delegate set-document-locs } document construct ; + V{ "" } clone document new-model + V{ } clone >>locs ; : add-loc ( loc document -- ) locs>> push ; From b8d9379b2bc42cef6c7e9910a57bb44a792f73c8 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Wed, 9 Jul 2008 12:22:07 -0500 Subject: [PATCH 3/3] bake and bake.fry: `[ == bake quotation '[ == fry quotation --- extra/bake/bake.factor | 3 ++- extra/bake/fry/fry-tests.factor | 42 ++++++++++++++++----------------- extra/bake/fry/fry.factor | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/extra/bake/bake.factor b/extra/bake/bake.factor index 0834c84c9a..748a811b34 100644 --- a/extra/bake/bake.factor +++ b/extra/bake/bake.factor @@ -92,5 +92,6 @@ MACRO: bake ( seq -- quot ) [bake] ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: `{ \ } [ >array ] parse-literal \ bake parsed ; parsing +: `{ \ } [ >array ] parse-literal \ bake parsed ; parsing : `V{ \ } [ >vector ] parse-literal \ bake parsed ; parsing +: `[ \ } [ >quotation ] parse-literal \ bake parsed ; parsing \ No newline at end of file diff --git a/extra/bake/fry/fry-tests.factor b/extra/bake/fry/fry-tests.factor index 13202a78f5..74408dc9f9 100755 --- a/extra/bake/fry/fry-tests.factor +++ b/extra/bake/fry/fry-tests.factor @@ -13,74 +13,74 @@ IN: bake.fry.tests ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -[ [ 3 + ] ] [ 3 `[ , + ] ] unit-test +[ [ 3 + ] ] [ 3 '[ , + ] ] unit-test -[ [ 1 3 + ] ] [ 1 3 `[ , , + ] ] unit-test +[ [ 1 3 + ] ] [ 1 3 '[ , , + ] ] unit-test -[ [ 1 + ] ] [ 1 [ + ] `[ , @ ] ] unit-test +[ [ 1 + ] ] [ 1 [ + ] '[ , @ ] ] unit-test -[ [ 1 + . ] ] [ 1 [ + ] `[ , @ . ] ] unit-test +[ [ 1 + . ] ] [ 1 [ + ] '[ , @ . ] ] unit-test -[ [ + - ] ] [ [ + ] [ - ] `[ @ @ ] ] unit-test +[ [ + - ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test [ [ "a" write "b" print ] ] -[ "a" "b" `[ , write , print ] ] unit-test +[ "a" "b" '[ , write , print ] ] unit-test [ [ 1 2 + 3 4 - ] ] -[ [ + ] [ - ] `[ 1 2 @ 3 4 @ ] ] unit-test +[ [ + ] [ - ] '[ 1 2 @ 3 4 @ ] ] unit-test [ 1/2 ] [ - 1 `[ , _ / ] 2 swap call + 1 '[ , _ / ] 2 swap call ] unit-test [ { { 1 "a" "A" } { 1 "b" "B" } { 1 "c" "C" } } ] [ - 1 `[ , _ _ 3array ] + 1 '[ , _ _ 3array ] { "a" "b" "c" } { "A" "B" "C" } rot 2map ] unit-test [ { { 1 "a" } { 1 "b" } { 1 "c" } } ] [ - `[ 1 _ 2array ] + '[ 1 _ 2array ] { "a" "b" "c" } swap map ] unit-test [ 1 2 ] [ - 1 2 `[ _ , ] call + 1 2 '[ _ , ] call ] unit-test [ { { 1 "a" 2 } { 1 "b" 2 } { 1 "c" 2 } } ] [ - 1 2 `[ , _ , 3array ] + 1 2 '[ , _ , 3array ] { "a" "b" "c" } swap map ] unit-test -: funny-dip `[ @ _ ] call ; inline +: funny-dip '[ @ _ ] call ; inline [ "hi" 3 ] [ "h" "i" 3 [ append ] funny-dip ] unit-test [ { 1 2 3 } ] [ - 3 1 `[ , [ , + ] map ] call + 3 1 '[ , [ , + ] map ] call ] unit-test [ { 1 { 2 { 3 } } } ] [ - 1 2 3 `[ , [ , [ , 1array ] call 2array ] call 2array ] call + 1 2 3 '[ , [ , [ , 1array ] call 2array ] call 2array ] call ] unit-test -{ 1 1 } [ `[ [ [ , ] ] ] ] must-infer-as +{ 1 1 } [ '[ [ [ , ] ] ] ] must-infer-as [ { { { 3 } } } ] [ - 3 `[ [ [ , 1array ] call 1array ] call 1array ] call + 3 '[ [ [ , 1array ] call 1array ] call 1array ] call ] unit-test [ { { { 3 } } } ] [ - 3 `[ [ [ , 1array ] call 1array ] call 1array ] call + 3 '[ [ [ , 1array ] call 1array ] call 1array ] call ] unit-test -! [ 10 20 30 40 `[ , V{ , { , } } , ] ] [ [ 10 V{ 20 { 30 } } 40 ] ] unit-test* +! [ 10 20 30 40 '[ , V{ , { , } } , ] ] [ [ 10 V{ 20 { 30 } } 40 ] ] unit-test* -[ 10 20 30 40 `[ , V{ , { , } } , ] ] +[ 10 20 30 40 '[ , V{ , { , } } , ] ] [ [ 10 20 30 >r r> 1 narray >r >r r> r> 2 narray >vector 40 ] ] unit-test* -[ { 1 2 3 } { 4 5 6 } { 7 8 9 } `[ , { V{ @ } { , } } ] call ] +[ { 1 2 3 } { 4 5 6 } { 7 8 9 } '[ , { V{ @ } { , } } ] call ] [ { 1 2 3 } { V{ 4 5 6 } { { 7 8 9 } } } diff --git a/extra/bake/fry/fry.factor b/extra/bake/fry/fry.factor index 6b069334e6..b9f9882e88 100644 --- a/extra/bake/fry/fry.factor +++ b/extra/bake/fry/fry.factor @@ -77,4 +77,4 @@ DEFER: shallow-fry MACRO: fry ( seq -- quot ) [fry] ; -: `[ \ ] [ >quotation ] parse-literal \ fry parsed ; parsing \ No newline at end of file +: '[ \ ] [ >quotation ] parse-literal \ fry parsed ; parsing \ No newline at end of file