all repos — min @ 14832e37a7b3a157d2d7c754d22335c57dbe718a

A small but practical concatenative programming language.

Listing items polluting the stack; other updates.
h3rald h3rald@h3rald.com
Sun, 17 Jan 2021 09:16:58 +0000
commit

14832e37a7b3a157d2d7c754d22335c57dbe718a

parent

ef2be2dbce670e25aa3c1c7bbaae9bd8b4498ca3

M min.vimmin.vim

@@ -1,8 +1,8 @@

" Vim syntax file " Language: min " Maintainer: Fabio Cevasco -" Last Change: 09 Jan 2021 -" Version: 0.28.0 +" Last Change: 17 Jan 2021 +" Version: 0.29.0 if exists("b:current_syntax") finish

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

setl iskeyword=@,36-39,+,-,*,.,/,:,~,!,48-57,60-65,94-95,192-255 setl iskeyword+=^ -syntax keyword minDefaultSymbol ! !! != # $ % & && ' * + - -> -inf . .. / : :: < <= = =% =-= == ==> => =~ > >< >= >> @ ROOT ^ accept acos aes all? and any? append apply apply-interpolate args asin ask atan atime bind bool boolean? call capitalize case cd ceil chmod choose chr clear clear-stack cleave close column-print compiled? concat confirm connect cons cos cosh cp cpu crypto ctime d2r datetime ddel ddup debug debug! decode decode-url define define-sigil defined-sigil? defined? delete delete-sigil dequote dget dhas? dict dictionary? difference dip dir? dirname div dkeys download dpairs dpick drop dsdelete dsdelete! dset dsget dshas? dsinit dspost dspost! dsput dsput! dsquery dsread dstore dswrite dswrite! dtype dup dvalues e encode encode-url env? error error! escape eval even? exists? exit expect expect-all expect-any expect-empty-stack fappend fatal fatal! file? filename filter find first flatten float float? floor foreach format-error fperms fread from-json from-semver from-yaml fs fsize fstats ftype fwrite get get-content get-env get-stack getchr gets hardlink harvest hidden? http id if import in? indent indexof inf infix-dequote info info! insert int integer? interpolate intersection invoke io join keep last length line-info linrec listen lite? ln load load-symbol log10 log2 logic loglevel loglevel? lowercase ls ls-r map map-reduce mapkey match math md4 md5 mini? mkdir mod module mtime mv nan net newline nip not notice notice! now null? num number? odd? one? operator opts or ord os over parse parse-url partition password pi pick pop pow pred prefix prefix-dequote prepend print print! prompt publish put-env putchr puts puts! quit quotation? quote quote-bind quote-define quote-map r2g raise random randomize raw-args recv recv-line reduce regex reject remove remove-symbol repeat replace request require rest return reverse rm rmdir rolldown rollup round run save-symbol saved-symbols scope scope-sigils scope-symbols seal seal-sigil search semver-inc-major semver-inc-minor semver-inc-patch semver? send seq set set-stack set-type sha1 sha224 sha256 sha384 sha512 shorten sigils sin sinh sip size sleep slice socket sort source split spread sqrt stack start-server stop-server str string string? strip substr succ suffix sum swap swons symbols symlink symlink? symmetric-difference sys system system! take tan tanh tap tap! tau tformat time timeinfo times timestamp titleize to-json to-semver to-timestamp to-yaml trunc try type type? union unless unmapkey unseal unseal-sigil unzip uppercase version warn warn! when which while with xor zip || +syntax keyword minDefaultSymbol ! !! != # $ % & && ' * + - -> -inf . .. / : :: < <= = =% =-= == ==> => =~ > >< >= >> @ ROOT ^ abs accept acos aes all? and any? append apply apply-interpolate args asin ask atan atime bind bool boolean? call capitalize case cd ceil chmod choose chr clear clear-stack cleave close column-print compiled? concat confirm connect cons cos cosh cp cpu crypto ctime d2r datetime ddel ddup debug debug! decode decode-url define define-sigil defined-sigil? defined? delete delete-sigil dequote dget dhas? dict dictionary? difference dip dir? dirname div dkeys download dpairs dpick drop dsdelete dsdelete! dset dsget dshas? dsinit dsinit! dspost dspost! dsput dsput! dsquery dsread dstore dswrite dswrite! dtype dup dvalues e encode encode-url env? error error! escape eval even? exists? exit expect expect-all expect-any expect-empty-stack fappend fatal fatal! file? filename filter find first flatten float float? floor foreach format-error fperms fread from-json from-semver from-yaml fs fsize fstats ftype fwrite get get-content get-env get-stack getchr gets hardlink harvest hidden? http id if import in? indent indexof inf infix-dequote info info! insert int integer? interpolate intersection invoke io join keep last length line-info linrec listen lite? ln load load-symbol log10 log2 logic loglevel loglevel? lowercase ls ls-r map map-reduce mapkey match math md4 md5 mini? mkdir mod module mtime mv nan net newline nip not notice notice! now null? num number? odd? one? operator opts or ord os over parse parse-url partition password pi pick pop pow pred prefix prefix-dequote prepend print print! prompt publish put-env putchr puts puts! quit quotation? quote quote-bind quote-define quote-map r2g raise random randomize raw-args recv recv-line reduce regex reject remove remove-symbol repeat replace request require rest return reverse rm rmdir rolldown rollup round run save-symbol saved-symbols scope scope-sigils scope-symbols seal seal-sigil sealed-sigil? sealed? search semver-inc-major semver-inc-minor semver-inc-patch semver? send seq set set-stack set-type sha1 sha224 sha256 sha384 sha512 shorten sigils sin sinh sip size sleep slice socket sort source split spread sqrt stack start-server stop-server str string string? stringlike? strip substr succ suffix sum swap swons symbols symlink symlink? symmetric-difference sys system system! take tan tanh tap tap! tau tformat time timeinfo times timestamp titleize to-json to-semver to-timestamp to-yaml trunc try type type? typeclass union unless unmapkey unseal unseal-sigil unzip uppercase version warn warn! when which while with xor zip || syntax match minDefaultSigil ;\<[/:@'~!?$%&=<>#^*#+]; contained syntax match minQuote ;\<['];
M minNotepad++.xmlminNotepad++.xml

@@ -24,12 +24,12 @@ <Keywords name="Folders in code2, close"></Keywords>

<Keywords name="Folders in comment, open"></Keywords> <Keywords name="Folders in comment, middle"></Keywords> <Keywords name="Folders in comment, close"></Keywords> - <Keywords name="Keywords1">puts import load apply args bind bool call case define define-sigil delete delete-sigil dequote expect expect-empty-stack float foreach format-error from-json from-yaml gets if import infix-dequote int invoke linrec load load-symbol loglevel module operator opts parse prefix-dequote prompt publish quit quote quote-bind quote-define raise read remove-symbol require reverse-expect-dequote return save-symbol scope saved-symbols scope-sigils scope-symbols seal seal-sigil set-type sigils source string symbols tap times to-json to-yaml try typeclass unless unseal unseal-sigil when while with clear-stack cleave cons dip dup get-stack id keep nip over pick pop rolldown rollup set-stack sip spread swap swons append get concat drop filter find first flatten harvest insert last map map-reduce partition prepend quote-map reduce reject remove rest reverse set shorten size slice sort take ddup ddel dget dkeys dpick dpairs dset dtype dvalues dsdelete dsget dsinit dspost dsput dsquery dsread dswrite ask choose clear column-print confirm debug error fappend fatal fread fwrite getchr info mapkey newline notice password print putchr type unmapkey warning atime ctime fperms fsize fstats ftype mtime expect-all expect-any apply-interpolate capitalize chr escape from-semver indent indexof interpolate join length lowercase match ord parse-url prefix repeat replace regex search semver-inc-major semver-inc-minor semver-inc-patch split strip substr suffix titleize to-semver uppercase chmod cd cp cpu dirname filename get-env hardlink ls ls-r mkdir mv os put-env rm rmdir run sleep symlink system unzip which zip div mod pred random succ sum now timestamp timeinfo to-timestamp datetime tformat aes decode encode md4 md5 sha1 sha224 sha256 sha384 sha512 acos asin atan ceil cos cosh d2r floor ln log10 log2 pow r2d round sin sinh sqrt tan tanh tau trunc accept close connect listen port recv recv-line send socket download get-content request start-server stop-server</Keywords> + <Keywords name="Keywords1">puts import load apply args bind bool call case define define-sigil delete delete-sigil dequote expect expect-empty-stack float foreach format-error from-json from-yaml gets if import infix-dequote int invoke linrec load load-symbol loglevel module operator opts parse prefix-dequote prompt publish quit quote quote-bind quote-define raise read remove-symbol require reverse-expect-dequote return save-symbol scope saved-symbols scope-sigils scope-symbols seal seal-sigil set-type sigils source string symbols tap times to-json to-yaml try typeclass unless unseal unseal-sigil when while with clear-stack cleave cons dip dup get-stack id keep nip over pick pop rolldown rollup set-stack sip spread swap swons append get concat drop filter find first flatten harvest insert last map map-reduce partition prepend quote-map reduce reject remove rest reverse set shorten size slice sort take ddup ddel dget dkeys dpick dpairs dset dtype dvalues dsdelete dsget dsinit dspost dsput dsquery dsread dswrite ask choose clear column-print confirm debug error fappend fatal fread fwrite getchr info mapkey newline notice password print putchr type unmapkey warning atime ctime fperms fsize fstats ftype mtime expect-all expect-any apply-interpolate capitalize chr escape from-semver indent indexof interpolate join length lowercase match ord parse-url prefix repeat replace regex search semver-inc-major semver-inc-minor semver-inc-patch split strip substr suffix titleize to-semver uppercase chmod cd cp cpu dirname filename get-env hardlink ls ls-r mkdir mv os put-env rm rmdir run sleep symlink system unzip which zip div mod pred random succ sum now timestamp timeinfo to-timestamp datetime tformat aes decode encode md4 md5 sha1 sha224 sha256 sha384 sha512 acos asin atan ceil cos cosh d2r floor ln log10 log2 pow r2d round sin sinh sqrt tan tanh tau trunc accept close connect listen port recv recv-line send socket download get-content request start-server stop-server abs dsinit!</Keywords> <Keywords name="Keywords2">== &gt;= &lt;= &gt; &lt; != and expect-all expect-any or not xor</Keywords> <Keywords name="Keywords3">: + @ = # ~ ^ * &gt; &lt; / ? % $ ! &amp;</Keywords> <Keywords name="Keywords4">eval exit ROOT version</Keywords> <Keywords name="Keywords5">-&gt; =&gt;</Keywords> - <Keywords name="Keywords6">compiled? defined? lite? loglevel? all? any? in? dhas? hidden? boolean? dictionary? float? integer? null? number? quotation? type? semver? env? dir? exists? file? symlink? stringlike? even? odd?</Keywords> + <Keywords name="Keywords6">compiled? defined? lite? loglevel? all? any? in? dhas? hidden? boolean? dictionary? float? integer? null? number? quotation? type? semver? env? dir? exists? file? symlink? stringlike? even? odd? sealed?</Keywords> <Keywords name="Keywords7">puts! tap! debug! error! info! notice! print! warning! system!</Keywords> <Keywords name="Keywords8">+ - -inf * / inf nan randomize e pi</Keywords> <Keywords name="Delimiters">00&quot; 01 02&quot; 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
M minpkg/core/interpreter.nimminpkg/core/interpreter.nim

@@ -32,6 +32,11 @@ var CACHEDMODULES* {.threadvar.}: CritBitTree[MinValue]

const USER_SYMBOL_REGEX* = "^[a-zA-Z_][a-zA-Z0-9/!?+*._-]*$" +proc diff*(a, b: seq[MinValue]): seq[MinValue] = + result = newSeq[MinValue](0) + for it in b: + if not a.contains it: + result.add it proc newSym*(i: In, s: string): MinValue = return MinValue(kind: minSymbol, symVal: s, filename: i.currSym.filename, line: i.currSym.line, column: i.currSym.column, outerSym: i.currSym.symVal)

@@ -402,8 +407,9 @@ i2.withScope:

i2.open(newStringStream(contents), s) discard i2.parser.getToken() discard i2.interpret(parseOnly) - if snapshot != i2.stack: - raiseInvalid("Module '$#' is polluting the stack" % s) + let d = snapshot.diff(i2.stack) + if d.len > 0: + raiseInvalid("Module '$#' is polluting the stack -- $#" % [s, $d.newVal]) result = newDict(i2.scope) result.objType = "module" for key, value in i2.scope.symbols.pairs:

@@ -418,4 +424,4 @@ return i.load(s, true)

# Inherit file/line/column from current symbol proc pushSym*(i: In, s: string) = - i.push MinValue(kind: minSymbol, symVal: s, filename: i.currSym.filename, line: i.currSym.line, column: i.currSym.column, outerSym: i.currSym.symVal)+ i.push MinValue(kind: minSymbol, symVal: s, filename: i.currSym.filename, line: i.currSym.line, column: i.currSym.column, outerSym: i.currSym.symVal)
M minpkg/core/utils.nimminpkg/core/utils.nim

@@ -41,7 +41,7 @@ i.push mdl

i.evaluating = false if name != "": scope.previous.symbols[name] = MinOperator(kind: minProcOp, prc: op) - + # Dictionary Methods proc dget*(i: In, q: MinValue, s: MinValue): MinValue =
M minpkg/lib/min_lang.nimminpkg/lib/min_lang.nim

@@ -266,8 +266,9 @@ try:

snapshot = deepCopy(i.stack) i.dequote bv endSnapshot = i.stack - if endSnapshot != snapshot: - raiseInvalid("Operator '$#' is polluting the stack" % n) + let d= snapshot.diff(endSnapshot) + if d.len > 0 : + raiseInvalid("Operator '$#' is polluting the stack -- $#" % [n, $d.newVal]) except MinReturnException: discard # Validate output
M next-release.mdnext-release.md

@@ -5,3 +5,5 @@ * Added **abs** symbol.

* Now executing min shell if no file is specified (unless input is piped in), without the need of specifying **-i**. * Implemented the possibility to define type classes using the **typeclass** symbol. * Added **stringlike?** symbol. +* Implemented support for generics in operator signatures +* Now listing what items are polluting the stack.