Implemented confirm operator.
h3rald h3rald@h3rald.com
Sun, 02 Oct 2016 16:20:03 +0200
3 files changed,
24 insertions(+),
6 deletions(-)
M
lib/min_io.nim
→
lib/min_io.nim
@@ -3,6 +3,7 @@ os,
strutils import ../core/linedit, + ../core/regex, ../core/parser, ../core/value, ../core/interpreter,@@ -17,7 +18,7 @@
.symbol("newline") do (i: In): echo "" - .symbol("put") do (i: In): + .symbol("puts") do (i: In): let a = i.peek echo $$a@@ -32,12 +33,29 @@ if c mod n.intVal == 0:
echo "" echo "" - .symbol("get") do (i: In): - i.push stdin.readLine().newVal + .symbol("gets") do (i: In): + var ed = initEditor() + i.push ed.readLine().newVal .symbol("password") do (i: In): var ed = initEditor() i.push ed.password("Enter Password: ").newVal + + .symbol("confirm") do (i: In): + var s: MinValue + var ed = initEditor() + i.reqString s + stdout.write(s.getString & " [yes/no]: ") + proc confirm(): bool = + let answer = ed.readLine() + if answer.match("^y(es)?$", "i"): + return true + elif answer.match("^no?$", "i"): + return false + else: + stdout.write "Invalid answer. Please enter 'yes' or 'no': " + return confirm() + i.push confirm().newVal .symbol("print") do (i: In): let a = i.peek
M
minim.vim
→
minim.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 case cd chmod choose clear-stack column-print concat confirm 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! prompt 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 keyword minimDefaultSymbol ! != $ & ' * + - -> . .. / : < <= == => =~ > >= @ ROOT aes and append apply 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 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 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 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
prelude.min
→
prelude.min
@@ -18,7 +18,7 @@ '> :gt
'< :lt '>= :gte '<= :lte -'put :echo +'puts :echo 'system :! 'run :& 'getenv :$@@ -61,7 +61,7 @@
; Other (print pop) :print! (dprint pop) :dprint! -(put pop) :put! +(puts pop) :puts! (call pop) :call! (:ms :q :check (check) (ms sleep q) while) :interval (password aes encode) :encrypt