diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-07-06 01:41:37 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-07-06 01:44:32 -0700 |
commit | c72d831021051afe144907d6cb594d8d6e0281aa (patch) | |
tree | 1e90ea3e18d6e6a2a4d21950caa9ebfa011c1eaa | |
parent | e74ff41321eded0d2e22449b17ac29c38f3abf2c (diff) | |
download | mu-c72d831021051afe144907d6cb594d8d6e0281aa.tar.gz |
1
-rw-r--r-- | mu.arc | 22 | ||||
-rw-r--r-- | mu.arc.t | 6 | ||||
-rw-r--r-- | x.mu | 10 |
3 files changed, 27 insertions, 11 deletions
diff --git a/mu.arc b/mu.arc index 3c02fcec..6990d35c 100644 --- a/mu.arc +++ b/mu.arc @@ -1,5 +1,12 @@ -(= types* (table)) -(= memory* (table)) +(def clear () + (= types* (table)) + (= memory* (table)) + (= function* (table))) +(clear) + +(def add-fns (fns) + (each (name . body) fns + (= function*.name body))) (def run (instrs) (each instr instrs @@ -12,9 +19,14 @@ add (= memory*.oarg1 (+ memory*.arg1 memory*.arg2)) + ; else + (prn "aaa") ; user-defined functions go here )))) -(each file (cut argv 1) -;? (prn file) - (run readfile.file) +(awhen cdr.argv + (each file it + ;? (prn file) + (add-fns readfile.file)) + ;? (prn function*) + (run function*!main) (prn memory*)) diff --git a/mu.arc.t b/mu.arc.t index 72cbad74..85dd1cc5 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -1,8 +1,10 @@ (load "mu.arc") -(run '( +(clear) +(add-fns '((test1 (1 <- loadi 1) (2 <- loadi 3) - (3 <- add 1 2))) + (3 <- add 1 2)))) +(run function*!test1) (if (~iso memory* (obj 1 1 2 3 3 4)) (prn "F - load and add instructions work")) diff --git a/x.mu b/x.mu index 06b62c25..6fbfaec0 100644 --- a/x.mu +++ b/x.mu @@ -1,4 +1,6 @@ -(1 <- loadi 1) -(2 <- loadi 3) -(3 <- add 1 2) -(prn 3) +(main + (1 <- loadi 1) + (2 <- loadi 3) + (3 <- add 1 2) + (x <- prn a) +) |