all repos — min @ 3b934ce0ee203fe26153593b1ce0fc3c61b64cdc

A small but practical concatenative programming language.

Added vim highlighting file; minor changes.
h3rald h3rald@h3rald.com
Sun, 18 Sep 2016 15:55:04 +0200
commit

3b934ce0ee203fe26153593b1ce0fc3c61b64cdc

parent

4fbd3d912f60eadd2a13457f913ec423aeb2f275

4 files changed, 71 insertions(+), 12 deletions(-)

jump to
M core/utils.nimcore/utils.nim

@@ -10,7 +10,7 @@ # Library methods

proc previous(scope: ref MinScope): ref MinScope = if scope.parent.isNil: - return scope #### was: ROOT + return scope else: return scope.parent
M lib/min_crypto.nimlib/min_crypto.nim

@@ -8,6 +8,7 @@ ../core/parser,

../core/value, ../core/interpreter, ../core/utils, +import ../vendor/sha1, ../vendor/nimSHA2, ../vendor/nimAES
M minim.nimminim.nim

@@ -1,4 +1,11 @@

-import streams, critbits, parseopt2, strutils, os, json, sequtils +import + streams, + critbits, + parseopt2, + strutils, + os, + json, + sequtils import core/linedit, core/consts,

@@ -20,20 +27,19 @@

var REPL = false var DEBUGGING = false const PRELUDE* = "prelude.min".slurp.strip -let usage* = " " & appname & " v" & version & " - a tiny concatenative programming language" & """ - +let usage* = """ $1 v$2 - a tiny concatenative shell and programming language (c) 2014-2016 Fabio Cevasco Usage: minim [options] [filename] Arguments: - filename A minim file to interpret (default: STDIN). + filename A $1 file to interpret (default: STDIN). Options: - -e, --evaluate Evaluate a minim program inline + -e, --evaluate Evaluate a $1 program inline -h, --help Print this help -v, --version Print the program version - -i, --interactive Start MiNiM Shell""" + -i, --interactive Start $1 shell""" % [appname, version] proc getExecs(): seq[string] =

@@ -67,7 +73,7 @@ return symbols.mapIt("*" & $it)

if word.startsWith("("): return symbols.mapIt("(" & $it) if word.startsWith("<"): - return toSeq(MINIMSYMBOLS.readFile.parseJson.pairs).mapIt(">" & $it[0]) + return toSeq(MINIMSYMBOLS.readFile.parseJson.pairs).mapIt("<" & $it[0]) if word.startsWith("$"): return toSeq(envPairs()).mapIt("$" & $it[0]) if word.startsWith("!"):

@@ -78,21 +84,21 @@ if word.startsWith("\""):

var f = word[1..^1] if f == "": f = getCurrentDir().replace("\\", "/") - return toSeq(walkDir(f, true)).mapIt("\"$1\"" % it.path.replace("\\", "/")) + return toSeq(walkDir(f, true)).mapIt("\"$1" % it.path.replace("\\", "/")) elif f.dirExists: f = f.replace("\\", "/") if f[f.len-1] != '/': f = f & "/" - return toSeq(walkDir(f, true)).mapIt("\"$1$2\"" % [f, it.path.replace("\\", "/")]) + return toSeq(walkDir(f, true)).mapIt("\"$1$2" % [f, it.path.replace("\\", "/")]) else: var dir: string if f.contains("/") or dir.contains("\\"): dir = f.parentDir let file = f.extractFileName - return toSeq(walkDir(dir, true)).filterIt(it.path.startsWith(file)).mapIt("\"$1/$2\"" % [dir, it.path.replace("\\", "/")]) + return toSeq(walkDir(dir, true)).filterIt(it.path.startsWith(file)).mapIt("\"$1/$2" % [dir, it.path.replace("\\", "/")]) else: dir = getCurrentDir() - return toSeq(walkDir(dir, true)).filterIt(it.path.startsWith(f)).mapIt("\"$1\"" % [it.path.replace("\\", "/")]) + return toSeq(walkDir(dir, true)).filterIt(it.path.startsWith(f)).mapIt("\"$1" % [it.path.replace("\\", "/")]) return symbols proc stdLib(i: In) =
A minim.vim

@@ -0,0 +1,52 @@

+" Vim syntax file +" Language: MiNiM +" Maintainer: Fabio Cevasco +" Last Change: 15 September 2016 +" Version: 1.0.0 + +if exists("b:current_syntax") + finish +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 match minimDefaultSigil ;\<[:@'~!$%&$=<>*]; contained +syntax match minimQuote ;\<[']; +syntax match minimBinding ;@; + +syntax keyword minimCommentTodo TODO FIXME XXX TBD contained +syntax match minimComment /;.*$/ contains=minimCommentTodo + +syntax match minimNumber ;[-+]\=\d\+\(\.\d*\)\=; +syntax keyword minimBoolean true false +syntax region minimString start=+"+ skip=+\\\\\|\\$"+ end=+"+ + +syntax region minimSigilSymbol start=;\<[:@'~!$%&$=<>*]; end=;\>; contains=minimDefaultSigil +syntax region minimQuotedSymbol start=;\<[']; end=;\>; contains=minimQuote +syntax region minimBoundSymbol start=;@; end=;\>; contains=minimBinding +syntax match minimSymbol ;[a-zA-Z_][a-zA-Z0-9/!?_-]*; + +syntax match minimParen ;(\|); + + + +" Highlighting +hi default link minimComment Comment +hi default link minimCommentTodo Todo +hi default link minimString String +hi default link minimSigilSymbol String +hi default link minimNumber Number +hi default link minimBoolean Boolean +hi default link minimDefaultSymbol Statement +hi default link minimQuote Delimiter +hi default link minimBinding Delimiter +hi default link minimDefaultSigil Delimiter +hi default link minimSymbol Identifier +hi default link minimQuotedSymbol Special +hi default link minimBoundSymbol Special +hi default link minimParen Special + +let b:current_syntax = "minim"