all repos — min @ cc91707eaf09e9fad949c8be8224e1fbb99ab46c

A small but practical concatenative programming language.

Added defined?, modified exit to return error code
h3rald h3rald@h3rald.com
Sun, 09 Jul 2017 12:14:29 +0200
commit

cc91707eaf09e9fad949c8be8224e1fbb99ab46c

parent

94b7a4520dbb42d36a77e41414b1e93ee7d93dab

7 files changed, 16 insertions(+), 5 deletions(-)

jump to
M .travis.yml.travis.yml

@@ -49,7 +49,6 @@ before_script:

- export PATH="$PATH:$PWD/nifty:$PWD/nim-$BRANCH/bin" script: - nifty install - - nifty build discount - nim c --cc:$CC --verbosity:0 -d:release min.nim - ./min tests/all.min cache:
M lib/min_lang.nimlib/min_lang.nim

@@ -20,7 +20,8 @@

proc lang_module*(i: In) = let def = i.scope def.symbol("exit") do (i: In): - quit(0) + let vals = i.expect("int") + quit(vals[0].intVal.int) def.symbol("symbols") do (i: In): var q = newSeq[MinValue](0)

@@ -30,6 +31,10 @@ for s in scope.symbols.keys:

q.add s.newVal scope = scope.parent i.push q.newVal(i.scope) + + def.symbol("defined?") do (i: In): + let vals = i.expect("'sym") + i.push(i.scope.hasSymbol(vals[0].getString).newVal) def.symbol("sigils") do (i: In): var q = newSeq[MinValue](0)
M min.vimmin.vim

@@ -11,7 +11,7 @@

setl iskeyword=@,36-39,+,-,/,*,.,:,~,!,48-57,60-65,94-95,192-255 setl iskeyword+=^ -syntax keyword minDefaultSymbol ! != $ & ' * + # - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes all? and any? append args ask atime bind bool boolean? call call! capitalize case cd chmod choose clear-stack cleave column-print concat confirm cons cp cpu crypto ctime datetime ddel debug decode define delete dget dictionary? dip dir? dirname div dprint dprint! dset dup encode env? error eval even? exists? exit expect fappend fatal find file? filename filter first flatten float float? foreach fperms fread from-json format-error fs fsize fstats ftype fwrite get gets get-env get-stack hardlink harvest hidden? id if import in? indent indexof info insert int integer? interpolate interval io join keep keys length linrec load load-symbol logic loglevel loglevel? lowercase ls ls-r map map-reduce match md5 mkdir mod module module-symbols module-sigils mtime mv newline nip not notice now num number? odd? opts os over partition password pick pop popd pred prepend print print! prompt publish puts puts! put-env q quotation? quote quote-bind quote-define random raise reduce regex reject remove remove-symbol repeat replace rest reverse rm rmdir run save-symbol scope scope? seal search seq set set-stack sha1 sha224 sha256 sha384 sha512 shorten sigils sip size sleep slice sort source split spread stack startup stored-symbols str string string? strip succ sum swap swons symbols symlink symlink? sys system take tformat time timeinfo times timestamp titleize to-json to-timestamp try unquote uppercase unzip values version warn when which while with xor zip +syntax keyword minDefaultSymbol ! != $ & ' * + # - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes all? and any? append args ask atime bind bool boolean? call call! capitalize case cd chmod choose clear-stack cleave column-print concat confirm cons cp cpu crypto ctime datetime ddel debug decode define defined? delete dget dictionary? dip dir? dirname div dprint dprint! dset dup encode env? error eval even? exists? exit expect fappend fatal find file? filename filter first flatten float float? foreach fperms fread from-json format-error fs fsize fstats ftype fwrite get gets get-env get-stack hardlink harvest hidden? id if import in? indent indexof info insert int integer? interpolate interval io join keep keys length linrec load load-symbol logic loglevel loglevel? lowercase ls ls-r map map-reduce match md5 mkdir mod module module-symbols module-sigils mtime mv newline nip not notice now num number? odd? opts os over partition password pick pop popd pred prepend print print! prompt publish puts puts! put-env q quotation? quote quote-bind quote-define random raise reduce regex reject remove remove-symbol repeat replace rest reverse rm rmdir run save-symbol scope scope? seal search seq set set-stack sha1 sha224 sha256 sha384 sha512 shorten sigils sip size sleep slice sort source split spread stack startup stored-symbols str string string? strip succ sum swap swons symbols symlink symlink? sys system take tformat time timeinfo times timestamp titleize to-json to-timestamp try unquote uppercase unzip values version warn when which while with xor zip syntax match minDefaultSigil ;\<[:@'~!$%&$=<>#^*#+/]; contained
M tests/all.mintests/all.min

@@ -1,4 +1,5 @@

; Load test files +0 :failures 'lang load 'stack load 'seq load

@@ -10,3 +11,4 @@ 'sys load

'time load 'fs load 'crypto load +failures exit
M tests/lang.mintests/lang.min

@@ -14,6 +14,8 @@ (2 'a define

(3 a + (5 'a define a) -> +) -> a + 12 ==) assert (symbols "a" in? false ==) assert + + ('abcdefg defined? false ==) assert 5 :five (symbols "five" in?) assert
M tests/sys.mintests/sys.min

@@ -30,7 +30,7 @@

("systest" cd . "systest" match) assert .. cd - ("minim -v" & 'output dget "\." match) assert + ("./min -v" & 'output dget "\." match) assert ("PATH" env?) assert
M tests/test.mintests/test.min

@@ -49,7 +49,10 @@ (

=result result (ok !=) - (padding "FAILED: " print! result puts!) + ( + ('failures defined?) (failures succ @failures) () if + padding "FAILED: " print! result puts! + ) () if )