]> gitweb.factorcode.org Git - factor.git/blob - basis/literals/literals.factor
Merge branch 'master' of git://github.com/abeaumont/factor
[factor.git] / basis / literals / literals.factor
1 ! (c) Joe Groff, see license for details
2 USING: accessors continuations kernel parser words quotations
3 combinators.smart vectors sequences fry ;
4 IN: literals
5
6 <PRIVATE
7
8 ! Use def>> call so that CONSTANT:s defined in the same file can
9 ! be called
10
11 : expand-literal ( seq obj -- seq' )
12     '[ _ dup word? [ def>> call ] when ] with-datastack ;
13
14 : expand-literals ( seq -- seq' )
15     [ [ { } ] dip expand-literal ] map concat ;
16
17 PRIVATE>
18
19 SYNTAX: $ scan-word expand-literal >vector ;
20 SYNTAX: $[ parse-quotation with-datastack >vector ;
21 SYNTAX: ${ \ } [ expand-literals ] parse-literal ;
22
23 SYNTAX: $$
24     scan-word execute( accum -- accum ) dup pop [ >quotation ] keep
25     [ output>sequence ] 2curry call( -- object ) parsed ;