aboutsummaryrefslogtreecommitdiff
path: root/test2.lang
diff options
context:
space:
mode:
authorEduardo Julian2015-01-03 02:31:14 -0400
committerEduardo Julian2015-01-03 02:31:14 -0400
commit212dd66966a873e3d7183b071f719ef58e4d88fe (patch)
tree0768fad2a0a88e7a91d7b542f32471a02eaea9b7 /test2.lang
parent648110a554a13e1caaf846a60c85cccadcda6e0d (diff)
- Beginning to implement compiler in the language itself.
- The language can now handle more symbols on identifiers.
Diffstat (limited to 'test2.lang')
-rw-r--r--test2.lang47
1 files changed, 46 insertions, 1 deletions
diff --git a/test2.lang b/test2.lang
index 243ab902a..13fabc59a 100644
--- a/test2.lang
+++ b/test2.lang
@@ -1,5 +1,5 @@
(import java.lang.System)
-## (require "./another" as another)
+(require "./another" as another)
(definterface Function
(: apply (-> [java.lang.Object] java.lang.Object)))
@@ -46,6 +46,51 @@
(#Quote form*)
)))
+## Utils
+(def (fail* message)
+ (#Failure message))
+
+(def (return* state value)
+ (#Ok state value))
+
+(def (fail message)
+ (lambda [state]
+ (#Failure message)))
+
+(def (return value)
+ (lambda [state]
+ (#Ok state value)))
+
+(def (bind m-value step)
+ (lambda [state]
+ (let inputs (m-value state)
+ (case inputs
+ (#Ok ?state ?datum)
+ (step ?datum ?state)
+
+ _
+ inputs))))
+
+## Ideally, this is what I want...
+## (exec [yolo lol
+## #let [foo bar]
+## #when foo]
+## (meme yolo foo))
+
+(defmacro (exec tokens)
+ (case tokens
+ (#Cons (#Tuple steps) (#Cons return #Nil))
+ (if (= 0 (mod (length steps) 2))
+ (fold (lambda [inner pair]
+ (case pair
+ [label computation]
+ (` (bind (~ computation)
+ (lambda [(~ label)] (~ inner))))))
+ return
+ (as-pairs steps))
+ (#Text "Oh no!"))))
+
+## Program
(def (main args)
(case (' ((~ "TROLOLOL")))
(#Form (#Cons (#Text text) #Nil))