]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/literals/literals.factor
basis: use lint.vocabs tool to trim using lists
[factor.git] / basis / literals / literals.factor
index e55d78ab6ef183781192d04f69da15f90b4ded77..4813f0d15cd1e860ddb0a999570bb1ff79b57e21 100644 (file)
@@ -1,6 +1,31 @@
 ! (c) Joe Groff, see license for details
-USING: accessors continuations kernel parser words quotations vectors ;
+USING: accessors continuations fry kernel lexer math parser
+sequences vectors words words.alias ;
 IN: literals
 
-SYNTAX: $ scan-word [ def>> call ] curry with-datastack >vector ;
+<PRIVATE
+
+! Use def>> 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' )
+    '[
+        _ expand-alias dup word? [ def>> call ] when
+    ] with-datastack ;
+
+: expand-literals ( seq -- seq' )
+    { } [ expand-literal ] reduce ;
+
+PRIVATE>
+
+SYNTAX: $ scan-word expand-literal >vector ;
 SYNTAX: $[ parse-quotation with-datastack >vector ;
+SYNTAX: ${ \ } [ expand-literals ] parse-literal ;
+SYNTAX: flags{
+    \ } [
+        expand-literals
+        0 [ bitor ] reduce
+    ] parse-literal ;