all repos — min @ 8a2bdd17ba07c08d169f0e79191d6bca6c0adefd

A small but practical concatenative programming language.

Implemented source operator.
h3rald h3rald@h3rald.com
Fri, 23 Sep 2016 23:51:00 +0200
commit

8a2bdd17ba07c08d169f0e79191d6bca6c0adefd

parent

6fd42bc697954fe9e4d6bb6e3d317efb44fc42fa

3 files changed, 15 insertions(+), 3 deletions(-)

jump to
M lib/min_lang.nimlib/min_lang.nim

@@ -256,7 +256,7 @@ file = file & ".min"

i.load i.pwd.joinPath(file) .symbol("with") do (i: In): - var qscope, qprog: Minvalue + var qscope, qprog: MinValue i.reqTwoQuotations qscope, qprog if qscope.qVal.len > 0: # System modules are empty quotes and don't need to be unquoted

@@ -266,9 +266,19 @@ i.scope = qscope.scope

for v in qprog.qVal: i.push v i.scope = scope + + .symbol("source") do (i: In): + var s: MinValue + i.reqStringLike s + let str = s.getString + let sym = i.scope.getSymbol(str) + if sym.kind == minValOp: + i.push sym.val + else: + raiseInvalid("No source available for native symbol '$1'." % str) .symbol("call") do (i: In): - var symbol, q: Minvalue + var symbol, q: MinValue i.reqStringLike symbol i.reqQuotation q let s = symbol.getString
M minim.vimminim.vim

@@ -10,7 +10,7 @@ endif

setl iskeyword+=?,$,+,*,/,%,=,>,<,&,-,',.,:,@,~,! -syntax keyword minimDefaultSymbol ! != $ & ' * + - -> . .. / : < <= == => =~ > >= @ ROOT aes and append apply at atime b bind bool bool? bury1 bury2 bury3 c call call! capitalize cd chmod clear-stack column-print concat cons cp cpu crypto ctime datetime ddel debug debug? decode decrypt define delete dget dictionary? dig1 dig2 dig3 dip dir? dirname div dprint dprint! dset dump-stack dup dupd echo encode encrypt env? eq eval even? exit fappend file? filename filter first float float? foreach fperms fread from-json fs fsize fstats ftype fwrite get get-stack getenv gt gte hardlink hidden? i id ifte import indent inspect int int? interpolate interval io join k keys length linrec load load-symbol logic lowercase ls ls-r lt lte map match md5 mkdir mod module mtime mv newline not noteq now num number? odd? or os password pop popd pred prepend print print! put put! putenv q quit quotation? quote raise regex remove-symbol repeat replace rest rm rmdir run save-symbol scope scope? seal search select set-stack sha1 sha224 sha256 sha384 sha512 sigil sigils sip size sleep split 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 unit unquote uppercase values version which while with xor zap contains +syntax keyword minimDefaultSymbol ! != $ & ' * + - -> . .. / : < <= == => =~ > >= @ ROOT aes and append apply at atime b bind bool bool? bury1 bury2 bury3 c call call! capitalize cd chmod clear-stack column-print concat cons cp cpu crypto ctime datetime ddel debug debug? decode decrypt define delete dget dictionary? dig1 dig2 dig3 dip dir? dirname div dprint dprint! dset dump-stack dup dupd echo encode encrypt env? eq eval even? exit fappend file? filename filter first float float? foreach fperms fread from-json fs fsize fstats ftype fwrite get get-stack getenv gt gte hardlink hidden? i id ifte import indent inspect int int? interpolate interval io join k keys length linrec load load-symbol logic lowercase ls ls-r lt lte map match md5 mkdir mod module mtime mv newline not noteq now num number? odd? or os password pop popd pred prepend print print! put put! putenv q quit quotation? quote raise regex remove-symbol repeat replace rest rm rmdir run save-symbol scope scope? seal search select set-stack sha1 sha224 sha256 sha384 sha512 sigil sigils sip size sleep source split 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 unit unquote uppercase values version which while with xor zap contains syntax match minimDefaultSigil ;\<[:@'~!$%&$=<>*]; contained
M tests/lang.mintests/lang.min

@@ -159,6 +159,8 @@ ('sym1 remove-symbol stored-symbols "sym1" contains false ==) assert

(0 :temp (1 2 3) (temp + @temp) foreach 6 temp ==) assert + ('succ source (1 +) ==) assert + report ; Tidy up ~defmod