diff options
author | Eduardo Julian | 2015-01-03 02:31:14 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-01-03 02:31:14 -0400 |
commit | 212dd66966a873e3d7183b071f719ef58e4d88fe (patch) | |
tree | 0768fad2a0a88e7a91d7b542f32471a02eaea9b7 /test2.lang | |
parent | 648110a554a13e1caaf846a60c85cccadcda6e0d (diff) |
- Beginning to implement compiler in the language itself.
- The language can now handle more symbols on identifiers.
Diffstat (limited to '')
-rw-r--r-- | test2.lang | 47 |
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)) |