2 USING: kernel combinators arrays vectors quotations sequences splitting
3 parser macros sequences.deep
4 combinators.short-circuit combinators.conditional bake newfx ;
8 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
17 : ((shallow-fry)) ( accum quot adder -- result )
19 append swap dup empty?
21 [ [ prepose ] curry append ]
24 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26 : (shallow-fry) ( accum quot -- result )
32 { \ , [ [ curry ] ((shallow-fry)) ] }
33 { \ @ [ [ compose ] ((shallow-fry)) ] }
34 [ swap >r suffix r> (shallow-fry) ]
40 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42 : shallow-fry ( quot -- quot' ) [ ] swap (shallow-fry) ;
44 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
46 : deep-fry ( quot -- quot )
49 shallow-fry [ >r ] rot
50 deep-fry [ [ dip ] curry r> compose ] 4array concat
55 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
57 : bakeable? ( obj -- ? ) { [ array? ] [ vector? ] } 1|| ;
59 : fry-specifier? ( obj -- ? ) { , @ } member-of? ;
61 : count-inputs ( quot -- n ) flatten [ fry-specifier? ] count ;
63 : commas ( n -- seq ) , <repetition> ;
65 : [fry] ( quot -- quot' )
68 { [ callable? ] [ [ count-inputs commas ] [ [fry] ] bi append ] }
69 { [ bakeable? ] [ [ count-inputs commas ] [ [bake] ] bi append ] }
70 { [ drop t ] [ 1quotation ] }
76 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
78 MACRO: fry ( seq -- quot ) [fry] ;
80 : '[ \ ] [ >quotation ] parse-literal \ fry parsed ; parsing