aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorEduardo Julian2015-03-01 17:16:52 -0400
committerEduardo Julian2015-03-01 17:16:52 -0400
commit2caf39ea09ae96669466e0e17fd2949347acda7a (patch)
treed4faf386cbfca23ac759c9082f9588e8cd7308b9 /source
parent83a1a1510ca2e83711a80ff2eb961c5694306b9e (diff)
- Fixed some bugs with pattern matching and macros.
- Simplified the code for handling definitions and macros. - Slightly changed the names of the fields of tuple classes. - Added a (currently empty) optimization phase.
Diffstat (limited to '')
-rw-r--r--source/lux.lux84
1 files changed, 63 insertions, 21 deletions
diff --git a/source/lux.lux b/source/lux.lux
index 8c1cb5695..03c2a6054 100644
--- a/source/lux.lux
+++ b/source/lux.lux
@@ -5,33 +5,33 @@
(jvm;class Tuple0 java.lang.Object
[])
(jvm;class Tuple1 java.lang.Object
- [[java.lang.Object _1]])
+ [[java.lang.Object _0]])
(jvm;class Tuple2 java.lang.Object
- [[java.lang.Object _1] [java.lang.Object _2]])
+ [[java.lang.Object _0] [java.lang.Object _1]])
(jvm;class Tuple3 java.lang.Object
- [[java.lang.Object _1] [java.lang.Object _2]
- [java.lang.Object _3]])
+ [[java.lang.Object _0] [java.lang.Object _1]
+ [java.lang.Object _2]])
(jvm;class Tuple4 java.lang.Object
- [[java.lang.Object _1] [java.lang.Object _2]
- [java.lang.Object _3] [java.lang.Object _4]])
+ [[java.lang.Object _0] [java.lang.Object _1]
+ [java.lang.Object _2] [java.lang.Object _3]])
(jvm;class Tuple5 java.lang.Object
- [[java.lang.Object _1] [java.lang.Object _2]
- [java.lang.Object _3] [java.lang.Object _4]
- [java.lang.Object _5]])
+ [[java.lang.Object _0] [java.lang.Object _1]
+ [java.lang.Object _2] [java.lang.Object _3]
+ [java.lang.Object _4]])
(jvm;class Tuple6 java.lang.Object
- [[java.lang.Object _1] [java.lang.Object _2]
- [java.lang.Object _3] [java.lang.Object _4]
- [java.lang.Object _5] [java.lang.Object _6]])
+ [[java.lang.Object _0] [java.lang.Object _1]
+ [java.lang.Object _2] [java.lang.Object _3]
+ [java.lang.Object _4] [java.lang.Object _5]])
(jvm;class Tuple7 java.lang.Object
- [[java.lang.Object _1] [java.lang.Object _2]
- [java.lang.Object _3] [java.lang.Object _4]
- [java.lang.Object _5] [java.lang.Object _6]
- [java.lang.Object _7]])
+ [[java.lang.Object _0] [java.lang.Object _1]
+ [java.lang.Object _2] [java.lang.Object _3]
+ [java.lang.Object _4] [java.lang.Object _5]
+ [java.lang.Object _6]])
(jvm;class Tuple8 java.lang.Object
- [[java.lang.Object _1] [java.lang.Object _2]
- [java.lang.Object _3] [java.lang.Object _4]
- [java.lang.Object _5] [java.lang.Object _6]
- [java.lang.Object _7] [java.lang.Object _8]])
+ [[java.lang.Object _0] [java.lang.Object _1]
+ [java.lang.Object _2] [java.lang.Object _3]
+ [java.lang.Object _4] [java.lang.Object _5]
+ [java.lang.Object _6] [java.lang.Object _7]])
(jvm;class Variant java.lang.Object
[[java.lang.String tag] [java.lang.Object value]])
@@ -46,6 +46,49 @@
#Nil])
state])
)))
+(declare-macro let')
+
+(def' lambda
+ (lambda' _ tokens
+ (lambda' _ state
+ (let' output (case' tokens
+ (#Cons [(#Form (#Cons [self (#Cons [arg args'])])) (#Cons [body #Nil])])
+ (#Form (#Cons [(#Ident "lambda'")
+ (#Cons [self
+ (#Cons [arg
+ (#Cons [(case' args'
+ #Nil
+ body
+
+ _
+ (#Form (#Cons [(#Ident "lux;lambda")
+ (#Cons [(#Form (#Cons [(#Ident "_") args']))
+ (#Cons [body #Nil])])])))
+ #Nil])])])])))
+ [(#Cons [output #Nil]) state])
+ )))
+(declare-macro lambda)
+
+## (def' lambda
+## (lambda' _ tokens
+## (lambda' _ state
+## (let' output (case' tokens
+## (#Cons [(#Form (#Cons [self (#Cons [arg args'])])) (#Cons [body #Nil])])
+## (#Form (#Cons [(#Ident "lambda'")
+## (#Cons [self
+## (#Cons [arg
+## (#Cons [(case' args'
+## #Nil
+## body
+
+## _
+## (#Form (#Cons [(#Ident "lux;lambda")
+## (#Cons [(#Form (#Cons [(#Ident "_") args']))
+## (#Cons [body #Nil])])])))
+## #Nil])])])])))
+## [(#Cons [output #Nil]) state])
+## )))
+
## (def' lambda
## (lambda' _ tokens
@@ -66,7 +109,6 @@
## #Nil])])])])))
## [(#Cons output #Nil) state])
## )))
-## (declare-macro lambda)
## (def' def
## (lambda (_ tokens state)