Added append, exists?, and random symbols.
h3rald h3rald@h3rald.com
Sat, 25 Mar 2017 14:12:30 +0100
9 files changed,
36 insertions(+),
18 deletions(-)
M
lib/min_lang.nim
→
lib/min_lang.nim
@@ -352,6 +352,13 @@ let v = i.pop
q.qVal.add v i.push q + .symbol("prepend") do (i: In): + var q: MinValue + i.reqQuotation q + let v = i.pop + q.qVal = v & q.qVal + i.push q + .symbol("at") do (i: In): var index, q: MinValue i.reqIntAndQuotation index, q
M
lib/min_num.nim
→
lib/min_num.nim
@@ -69,6 +69,11 @@ i.push newVal(b.floatVal / a.floatVal)
else: i.push newVal(b.intVal.float / a.floatVal) + .symbol("random") do (i: In): + var n: MinValue + i.reqInt n + i.push n.intVal.int.random.newVal + .symbol("div") do (i: In): var a, b: MinValue i.reqTwoInts b, a
M
lib/min_stack.nim
→
lib/min_stack.nim
@@ -12,9 +12,6 @@ proc stack_module*(i: In)=
i.define() - .symbol("i") do (i: In): - i.push "unquote".newSym - .symbol("id") do (i: In): discard@@ -28,11 +25,11 @@ .symbol("popd") do (i: In):
i.push newVal(@["pop".newSym], i.scope) i.push "dip".newSym - # ((pop) dip i) + # ((pop) dip unquote) .symbol("k") do (i: In): i.push newVal(@["pop".newSym], i.scope) i.push "dip".newSym - i.push "i".newSym + i.push "unquote".newSym .symbol("dup") do (i: In): i.push i.peek@@ -42,11 +39,11 @@ .symbol("dupd") do (i: In):
i.push newVal(@["dup".newSym], i.scope) i.push "dip".newSym - #((dup) dip i) + #((dup) dip unquote) .symbol("q") do (i: In): i.push newVal(@["dup".newSym], i.scope) i.push "dip".newSym - i.push "i".newSym + i.push "unquote".newSym .symbol("dip") do (i: In): var q: MinValue@@ -74,11 +71,11 @@ .symbol("swapd") do (i: In):
i.push newVal(@["swap".newSym], i.scope) i.push "dip".newSym - # ((cons) dip i) + # ((swap) dip unquote) .symbol("c") do (i: In): i.push newVal(@["swap".newSym], i.scope) i.push "dip".newSym - i.push "i".newSym + i.push "unquote".newSym .symbol("cons") do (i: In): var q: MinValue@@ -108,26 +105,26 @@ i.push "cons".newSym
i.push "cons".newSym i.push "dip".newSym - # ((() cons) dip swap i) + # ((() cons) dip swap unquote) .symbol("bury1") do (i: In): i.push newVal(@[newVal(@[], i.scope), "cons".newSym], i.scope) i.push "dip".newSym i.push "swap".newSym - i.push "i".newSym + i.push "unquote".newSym - # ((() cons cons) dip swap i) + # ((() cons cons) dip swap unquote) .symbol("bury2") do (i: In): i.push newVal(@[newVal(@[], i.scope), "cons".newSym, "cons".newSym], i.scope) i.push "dip".newSym i.push "swap".newSym - i.push "i".newSym + i.push "unquote".newSym - # ((() cons cons cons) dip swap i) + # ((() cons cons cons) dip swap unquote) .symbol("bury3") do (i: In): i.push newVal(@[newVal(@[], i.scope), "cons".newSym, "cons".newSym, "cons".newSym], i.scope) i.push "dip".newSym i.push "swap".newSym - i.push "i".newSym + i.push "unquote".newSym .symbol("swons") do (i: In): i.push "swap".newSym
M
lib/min_sys.nim
→
lib/min_sys.nim
@@ -84,6 +84,11 @@
.symbol("cpu") do (i: In): i.push hostCPU.newVal + .symbol("exists?") do (i: In): + var f: MinValue + i.reqStringLike f + i.push newVal(f.getString.fileExists or f.getString.dirExists) + .symbol("file?") do (i: In): var f: MinValue i.reqStringLike f
M
min.vim
→
min.vim
@@ -11,7 +11,7 @@
setl iskeyword=@,36-39,+,-,/,*,.,:,~,!,48-57,60-65,94-95,192-255 setl iskeyword+=^ -syntax keyword minDefaultSymbol ! != $ & ' * + # - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes and append ask at atime b bind bool bool? bury1 bury2 bury3 c call call! capitalize case cd chmod choose clear-stack column-print concat confirm cons cp cpu crypto ctime datetime ddel debug decode decrypt define delete dget dictionary? dig1 dig2 dig3 dip dir? dirname div dprint dprint! dset dump-stack dup dupd encode encrypt env? error eval even? exit fappend fatal file? filename filter first float float? foreach fperms fread from-json format-error fs fsize fstats ftype fwrite gets get-stack getenv hardlink hidden? i id ift ifte import indent info inspect int int? interpolate interval io join k keys length linrec load load-symbol logic loglevel loglevel? lowercase ls ls-r map match md5 mkdir mod module module-symbols module-sigils mtime mv newline not notice now num number? odd? os password pop popd pred print print! prompt publish puts puts! putenv q quotation? quote quote-bind quote-define raise regex remove-symbol repeat replace rest rm rmdir run save-symbol scope scope? seal search set-stack sha1 sha224 sha256 sha384 sha512 sigils sip sleep sort source split startup stored-symbols str string string? strip succ swap swapd swons symbols symlink symlink? sys system take tformat time timeinfo times timestamp titleize to-json try unquote uppercase unzip values version warn which while with xor zip contains +syntax keyword minDefaultSymbol ! != $ & ' * + # - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes and append ask at atime b bind bool bool? bury1 bury2 bury3 c call call! capitalize case cd chmod choose clear-stack column-print concat confirm cons cp cpu crypto ctime datetime ddel debug decode define delete dget dictionary? dig1 dig2 dig3 dip dir? dirname div dprint dprint! dset dump-stack dup dupd encode env? error eval even? exists? exit fappend fatal file? filename filter first float float? foreach fperms fread from-json format-error fs fsize fstats ftype fwrite gets get-stack getenv hardlink hidden? id ift ifte import indent info inspect int int? interpolate interval io join k keys length linrec load load-symbol logic loglevel loglevel? lowercase ls ls-r map match md5 mkdir mod module module-symbols module-sigils mtime mv newline not notice now num number? odd? os password pop popd pred prepend print print! prompt publish puts puts! putenv q quotation? quote quote-bind quote-define random raise regex remove-symbol repeat replace rest rm rmdir run save-symbol scope scope? seal search set-stack sha1 sha224 sha256 sha384 sha512 sigils sip sleep sort source split startup stored-symbols str string string? strip succ swap swapd swons symbols symlink symlink? sys system take tformat time timeinfo times timestamp titleize to-json try unquote uppercase unzip values version warn which while with xor zip contains syntax match minDefaultSigil ;\<[:@'~!$%&$=<>#^*#+/]; contained
M
tests/lang.min
→
tests/lang.min
@@ -84,6 +84,8 @@ ((2 3) unquote get-stack (2 3) ==) assert
(4 (1 2 3) append (1 2 3 4) ==) assert + (0 (1 2 3) prepend (0 1 2 3) ==) assert + ((1 2 3 4) 2 at 3 ==) assert ((1 2 3) length 3 ==) assert
M
tests/num.min
→
tests/num.min
@@ -28,5 +28,7 @@ (5 2 mod 1 ==) assert
(4 2 mod 0 ==) assert (-3 2 mod -1 ==) assert + (1000 random 1000 <) assert + report clear-stack
M
tests/stack.min
→
tests/stack.min
@@ -5,8 +5,6 @@ "stack" describe
(1 id 1 ==) assert - (2 (2 +) i 4 ==) assert - (2 id 2 ==) assert (2 pop get-stack () ==) assert
M
tests/sys.min
→
tests/sys.min
@@ -44,6 +44,8 @@ (cpu length 0 >) assert
("TEST" "test.txt" fwrite "test.txt" file?) assert + ("systest" exists?) assert + ("systest" dir?) assert ("test.txt" "test2.txt" cp "test2.txt" file?) assert