all repos — min @ e3936769c898b6986367e6baeb3eb61c03397742

A small but practical concatenative programming language.

Added prefix and suffix.
h3rald h3rald@h3rald.com
Mon, 07 Dec 2020 03:57:47 +0100
commit

e3936769c898b6986367e6baeb3eb61c03397742

parent

787217a7882c70db4ba2ebec565ae1510dd9977e

M lib/min_str.nimlib/min_str.nim

@@ -214,6 +214,20 @@ let a = vals[0].getString

var s = "" a.escapeJsonUnquoted(s) i.push s.newVal + + def.symbol("prefix") do (i: In): + let vals = i.expect("'sym", "'sym") + let a = vals[1].getString + let b = vals[0].getString + var s = b & a + i.push s.newVal + + def.symbol("suffix") do (i: In): + let vals = i.expect("'sym", "'sym") + let a = vals[1].getString + let b = vals[0].getString + var s = a & b + i.push s.newVal def.symbol("=~") do (i: In): i.push("regex".newSym)
M next-release.mdnext-release.md

@@ -3,8 +3,9 @@ * Documented that it is possible also to interpolate with named placeholders, like this: `"Current Directory: $pwd" ("pwd" .) =%`

* Added **from-yaml** and **to-yaml** operators. Note that they only support dictionaries containing string values (primarily intended to access extremely simple YAML files containing just key/value pairs). * Added **from-semver**, **to-semver**, **semver-major**, **semver-minor**, **semver-patch**, **semver** operators to manage version strings conforming to [Semantic Versioning](https://semver.org/) (additional labels are not yet supported). * Automatically adding **.min** to files supplied to the min executable if they don't already end in .min. -* Fixed GC safety issues -* Now statically linking libssl and libcrypto on all platform to provide HTTPS support out of the box -* Now using a set of min tasks to perform a min release and other common operations +* Fixed GC safety issues. +* Now statically linking libssl and libcrypto on all platform to provide HTTPS support out of the box. +* Now using a set of min tasks to perform a min release and other common operations. * Added **escape** operator to escape quotes and special characters in a string. * Added **quit** operator to exit with a 0 code. +* Addes **prefix** and **suffix** operators to prepens and append one string to another.
M site/contents/reference-lang.mdsite/contents/reference-lang.md

@@ -270,6 +270,9 @@ > >

> Publish symbol [my-local-symbol](class:kwd) to [ROOT](class:kwd) scope: > > `'my-local-symbol ROOT publish` #} +{#op||quit||{{null}}||{{null}}|| +Exits the program or shell with 0 as return code. #} + {#op||quote||{{any}}||({{any}})|| Wraps {{any}} in a quotation. #}
M site/contents/reference-str.mdsite/contents/reference-str.md

@@ -71,6 +71,9 @@

{#op||ord||{{s}}||{{i}}|| Returns the ASCII code {{i}} corresponding to the single character {{s}}.#} +{#op||prefix||{{sl1}} {{sl2}}||{{s}}|| +Prepends {{sl2}} to {{sl1}}.#} + {#op||repeat||{{sl}} {{i}}||{{s}}|| Returns {{s}} containing {{sl}} repeated {{i}} times.#}

@@ -172,6 +175,9 @@ Returns {{s}}, which is set to {{sl}} with leading and trailing spaces removed.#}

{#op||substr||{{s1}} {{i1}} {{i2}}||{{s2}}|| Returns a substring {{s2}} obtained by retriving {{i2}} characters starting from index {{i1}} within {{s1}}.#} + +{#op||suffix||{{sl1}} {{sl2}}||{{s}}|| +Appends {{sl2}} to {{sl1}}.#} {#op||titleize||{{sl}}||{{s}}|| Returns a copy of {{sl}} in which the first character of each word is capitalized.#}
M tests/str.mintests/str.min

@@ -65,5 +65,13 @@ ("2.3.6" semver-inc-minor "2.4.6" ==) assert

("2.3.6" semver-inc-patch "2.3.7" ==) assert + ("4.6.5" semver? true ==) assert + + ("4.6.5.3" semver? false ==) assert + + ("fix" "pre" prefix "prefix" ==) assert + + ("suf" "fix" suffix "suffix" ==) assert + report clear-stack