]> gitweb.factorcode.org Git - factor.git/commitdiff
infix: crazy infix methods idea, dunno if it is awesome yet.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 15 Apr 2013 18:27:09 +0000 (11:27 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 15 Apr 2013 18:27:09 +0000 (11:27 -0700)
extra/infix/infix-tests.factor
extra/infix/infix.factor

index 8a729aa3445b56f4fd7103e92437d5f8187e4a9c..1c54de3a912d1e39848889e9fdcd8a7acc49f35b 100644 (file)
@@ -50,3 +50,7 @@ IN: infix.tests
 [ "rbo" ] [ [let "foobar" :> s [infix s[::-2] infix] ] ] unit-test
 [ "rbo" ] [ [let "foobar" :> s [infix s[:0:-2] infix] ] ] unit-test
 [ "rb" ] [ [let "foobar" :> s [infix s[:-5:-2] infix] ] ] unit-test
+
+INFIX:: foo ( x y -- z ) x**2-abs(y);
+
+{ 194 } [ 15 31 foo ] unit-test
index 8b15f1f3646d053d8d9440da0c5dd588f891e4a7..b81dc1db62792642c23d9d1189a25cd7e71b484e 100644 (file)
@@ -1,11 +1,9 @@
 ! Copyright (C) 2009 Philipp Brüschweiler
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs combinators combinators.short-circuit
-effects fry infix.parser infix.ast kernel locals locals.parser
-locals.types math math.functions math.order math.ranges
-multiline namespaces parser quotations sequences summary
-words vocabs.parser ;
-
+USING: accessors assocs combinators effects effects.parser fry
+infix.ast infix.parser kernel locals locals.parser math
+math.functions math.order math.ranges multiline namespaces
+parser quotations sequences summary words ;
 IN: infix
 
 <PRIVATE
@@ -120,3 +118,15 @@ PRIVATE>
 
 SYNTAX: [infix
     "infix]" parse-infix-quotation suffix! \ call suffix! ;
+
+<PRIVATE
+
+: (INFIX::) ( -- word def effect )
+    [
+        scan-new-word
+        [ ";" parse-infix-quotation ] parse-locals-definition
+    ] with-definition ;
+
+PRIVATE>
+
+SYNTAX: INFIX:: (INFIX::) define-declared ;