Removed sigil operator; sealed system-defined symbols.
h3rald h3rald@h3rald.com
Sat, 08 Oct 2016 15:55:36 +0200
5 files changed,
31 insertions(+),
20 deletions(-)
M
lib/min_lang.nim
→
lib/min_lang.nim
@@ -229,19 +229,19 @@ for sym, val in mdl.scope.symbols.pairs:
i.debug "[import] $1:$2" % [i.scope.name, sym] i.scope.symbols[sym] = val - .symbol("sigil") do (i: In): - var q1, q2: MinValue - i.reqTwoQuotations q1, q2 - if q1.qVal.len == 1 and q1.qVal[0].kind == minSymbol: - var symbol = q1.qVal[0].symVal - if symbol.len == 1: - if i.scope.hasSigil(symbol): - raiseInvalid("Sigil '$1' already exists" % [symbol]) - i.scope.sigils[symbol] = MinOperator(kind: minValOp, val: q2) - else: - raiseInvalid("A sigil can only have one character") - else: - raiseInvalid("The top quotation must contain only one symbol value") + #.symbol("sigil") do (i: In): + # var q1, q2: MinValue + # i.reqTwoQuotations q1, q2 + # if q1.qVal.len == 1 and q1.qVal[0].kind == minSymbol: + # var symbol = q1.qVal[0].symVal + # if symbol.len == 1: + # if i.scope.hasSigil(symbol): + # raiseInvalid("Sigil '$1' already exists" % [symbol]) + # i.scope.sigils[symbol] = MinOperator(kind: minValOp, val: q2) + # else: + # raiseInvalid("A sigil can only have one character") + # else: + # raiseInvalid("The top quotation must contain only one symbol value") .symbol("eval") do (i: In): var s: MinValue
M
minim.nim
→
minim.nim
@@ -154,9 +154,8 @@ i.stdLib()
var s = newStringStream("") i.open(s, "") var line: string - echo "$1 v$2" % [appname, version] + #echo "$1 v$2" % [appname, version] var ed = initEditor(historyFile = MINIMHISTORY) - i.apply(i.scope.getSymbol("startup")) while true: let symbols = toSeq(i.scope.symbols.keys) ed.completionCallback = proc(ed: LineEditor): seq[string] =
M
minim.vim
→
minim.vim
@@ -8,12 +8,15 @@ if exists("b:current_syntax")
finish endif -setl iskeyword+=?,$,+,*,/,%,=,>,<,&,-,',.,:,@,~,^,! +setl iskeyword+=?,$,+,*,/,%,=,>,<,&,-,',.,:,~,! +setl iskeyword+=^ +setl iskeyword+=@ -syntax keyword minimDefaultSymbol ! != $ & ' * + - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes and append apply 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 contains 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 gets get-stack getenv gt gte hardlink hidden? i id ifte import include 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! prompt puts puts! 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 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 unit unquote uppercase unzip values version which while with xor zap zip +syntax keyword minimDefaultSymbol ! != $ & ' * + - % ^ -> . .. / : < <= == => =~ > >= @ ROOT aes and append apply 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 debug? decode decrypt define 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 gets get-stack getenv gt gte hardlink hidden? i id ifte import include 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! prompt puts puts! 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 sigils sip size 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 unit unquote uppercase unzip values version which while with xor zap zip contains syntax match minimDefaultSigil ;\<[:@'~!$%&$=<>^*]; contained +syntax match minimSpecialSymbols ;[:@'~!$%&$=<>^*]; contained syntax match minimQuote ;\<[']; syntax match minimBinding ;@;
M
prelude.min
→
prelude.min
@@ -36,12 +36,15 @@ 'cons :prepend
'size :length 'regex :=~ +(': '@ 'quit 'eq 'noteq 'gt 'lt 'gte 'lte 'echo '! '& '$ '^ '% 'zap 'unit '' 'i 'apply '-> '=> 'select 'prepend 'length '=~) 'seal foreach + ; Mathematical Operators (1 +) :succ (1 -) :pred (2 mod 0 ==) :even? (even? not) :odd? +('succ 'pred 'even? 'odd?) 'seal foreach ; Stack Operators (swap cons) :swons@@ -60,6 +63,8 @@ ((() cons) dip swap i) :bury1
((() cons cons) dip swap i) :bury2 ((() cons cons cons) dip swap i) :bury3 +('swons 'popd 'dupd 'swapd 'q 'k 'b 'c 'take 'dig1 'dig2 'dig3 'bury1 'bury2 'bury3) 'seal foreach + ; Other (print pop) :print! (dprint pop) :dprint!@@ -69,11 +74,15 @@ (:ms :q :check (check) (ms sleep q) while) :interval
(password aes encode) :encrypt (decode password aes) :decrypt (dup load import) :include -() :startup + +('print! 'dprint! 'puts! 'call! 'interval 'encrypt 'decrypt 'include) 'seal foreach + -; Prompt +; Unsealed symbols +() :startup ("[$1]$$ " (.) %) :prompt ; Load all stored symbols stored-symbols ('load-symbol ROOT with) foreach +startup
M
tests/lang.min
→
tests/lang.min
@@ -55,7 +55,7 @@ 5 2 mymath ^myminus 3 ==) assert
(defmod mymath inspect ("myplus") ==) assert - ((":mysigil" concat) ', sigil ,test "test:mysigil" ==) assert + ;((":mysigil" concat) ', sigil ,test "test:mysigil" ==) assert ("3 4 +" eval 7 ==) assert