From 0d3dad21d594928f0985cc3b983e2355e40cc10d Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 31 Mar 2010 07:24:00 -0500 Subject: [PATCH] Make literals work with aliases, add flags{ parsing word to clean boilerplate with $[ --- basis/literals/literals.factor | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/basis/literals/literals.factor b/basis/literals/literals.factor index 001c56525f..3e541a80ce 100644 --- a/basis/literals/literals.factor +++ b/basis/literals/literals.factor @@ -1,6 +1,6 @@ ! (c) Joe Groff, see license for details -USING: accessors continuations kernel parser words quotations -vectors sequences fry ; +USING: accessors combinators continuations fry kernel lexer +math parser quotations sequences vectors words words.alias ; IN: literals > call so that CONSTANT:s defined in the same file can ! be called +: expand-alias ( obj -- obj' ) + dup alias? [ def>> first expand-alias ] when ; + : expand-literal ( seq obj -- seq' ) - '[ _ dup word? [ def>> call ] when ] with-datastack ; + '[ + _ expand-alias dup word? [ def>> call ] when + ] with-datastack ; : expand-literals ( seq -- seq' ) [ [ { } ] dip expand-literal ] map concat ; @@ -19,3 +24,7 @@ PRIVATE> SYNTAX: $ scan-word expand-literal >vector ; SYNTAX: $[ parse-quotation with-datastack >vector ; SYNTAX: ${ \ } [ expand-literals ] parse-literal ; +SYNTAX: flags{ + "}" [ parse-word ] map-tokens + expand-literals + 0 [ bitor ] reduce suffix! ;