all repos — min @ 96eeebcc8505b1be4fa435dbb8f54c38c866992d

A small but practical concatenative programming language.

Merge pull request #190 from jo-he/master

Fabio Cevasco h3rald@h3rald.com
Wed, 22 Feb 2023 04:37:48 +0100
commit

96eeebcc8505b1be4fa435dbb8f54c38c866992d

parent

64124466a7c5b31a4c4f433580314303c987180d

M minNotepad++.xmlminNotepad++.xml

@@ -24,13 +24,13 @@ <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 case define define-sigil delete-symbol 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 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-symbol seal-sigil sigils source string symbols tap times to-json to-yaml try unless unseal-symbol 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 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 typealias lambda</Keywords> + <Keywords name="Keywords1">puts import load apply args bind bool case define define-sigil delete-symbol 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 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-symbol seal-sigil sigils source string symbols tap times to-json to-yaml try unless unseal-symbol 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 dset-sym 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 warn 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 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 typealias lambda</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-symbol? loglevel? all? any? in? dhas? hidden? boolean? dictionary? float? integer? null? number? quotation? type? semver? env? dir? exists? file? symlink? stringlike? even? odd? sealed-symbol?</Keywords> - <Keywords name="Keywords7">puts! tap! debug! error! info! notice! print! warning! system!</Keywords> + <Keywords name="Keywords7">puts! tap! debug! error! info! notice! print! warn! 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> </KeywordLists>
M minpkg/lib/min_str.nimminpkg/lib/min_str.nim

@@ -291,9 +291,6 @@ let b = vals[0].getString

var s = a & b i.push s.newVal - def.symbol("=~") do (i: In): - i.pushSym("regex") - def.symbol("%") do (i: In): i.pushSym("interpolate")
M site/contents/get-started.mdsite/contents/get-started.md

@@ -39,6 +39,7 @@

#### -d:ssl If the **-d:ssl** flag is specified when compiling, min will be built with SSL support, so it will be possible to: + * perform HTTPS requests with the {#link-module||http#}. * use all the cryptographic symbols defined in the {#link-module||crypto#}.

@@ -111,7 +112,7 @@ > [$](class:prompt) cat myfile.min | min

> %tip% > -> You can enable _development mode_ (runtime checks and validations) by spacifying `-d` (`--dev`) when running a min program. If development mode is not enabled, min programs run faster. +> You can enable _development mode_ (runtime checks and validations) by specifying `-d` (`--dev`) when running a min program. If development mode is not enabled, min programs run faster. ## Compiling a min Program

@@ -152,4 +153,4 @@

* If you are using [Visual Studio Code](https://code.visualstudio.com/), you can install the official [min extension](https://marketplace.visualstudio.com/items?itemName=h3rald.vscode-min-lang) which provides syntax highlighting support, code folding, and auto-indentation. * If you are using [Vim](https://www.vim.org), a [min.vim](https://github.com/h3rald/min/blob/master/min.vim) syntax definition file is available in the min repo. * If you are using [Sublime Text 3](https://www.sublimetext.com/3), Rafael Carrasco created a min syntax definition file that is available [here](https://github.com/rscarrasco/min-sublime-syntax). -* If you are hsing [Notepad++](https://notepad-plus-plus.org), a [Notepad++ language file](https://github.com/h3rald/min/blob/master/minNotepad++.xml) contributed by baykus871 is available in tbe repo. +* If you are using [Notepad++](https://notepad-plus-plus.org), a [Notepad++ language file](https://github.com/h3rald/min/blob/master/minNotepad++.xml) contributed by baykus871 is available in the repo.
M site/contents/learn-definitions.mdsite/contents/learn-definitions.md

@@ -8,7 +8,7 @@

Being a concatenative language, min does not really need named parameters or variables: symbols just pop elements off the main stack in order, and that's normally enough. There is however one small problem with the traditional concatenative paradigm; consider the following program for example: dup dup - "\.zip$" match + "\.zip$" match? swap fsize 1000000 > and swap mtime now 3600 - >
M site/contents/learn-extending.mdsite/contents/learn-extending.md

@@ -19,13 +19,13 @@

To create a new module, simply create a file containing your operator definitions implemented using either the {#link-operator||lang||operator#} operator or the {#link-operator||lang||lambda#} operator ``` -(dup *) ^pow2 -(dup dup * *) ^pow3 -(dup dup dup * * *) ^pow4 +(dup *) ^pow2 +(dup dup * *) ^pow3 +(dup * dup *) ^pow4 ``` -Save your code to a file (e.g. *quickpows.min*) and you can use it in other nim files using the {#link-operator||lang||require#} operator and the {#link-operator||lang||import#} (if you want to import the operators in the current scope): +Save your code to a file (e.g. *quickpows.min*) and you can use it in other Nim files using the {#link-operator||lang||require#} operator and the {#link-operator||lang||import#} (if you want to import the operators in the current scope): ``` 'quickpows require :qp
M site/contents/reference-dict.mdsite/contents/reference-dict.md

@@ -46,12 +46,12 @@ > > {5 :q 4 :a 6 :c 7 :d "d" :a} ("a" "d") dpick

#} {#op||dpairs||{{d}}||({{a0p}})|| -Returns a quotation containing all the keys (odd items) and values (even items) of dictiionary {{d}}. #} +Returns a quotation containing all the keys (odd items) and values (even items) of dictionary {{d}}. #} {#op||dset||{{d}} {{any}} {{sl}}||{{d}}|| Sets the value of the {{sl}} of {{d1}} to {{any}}, and returns the modified dictionary {{d}}. #} -{#op||dset||{{d}} {{sl}} {{sl}}||{{d}}|| +{#op||dset-sym||{{d}} {{sl}} {{sl}}||{{d}}|| Sets the value of the {{sl}} of {{d1}} to {{sl}} (treating it as a symbol), and returns the modified dictionary {{d}}. #} {#op||dtype||{{d}}||{{s}}||
M site/contents/reference-http.mdsite/contents/reference-http.md

@@ -67,7 +67,7 @@ > > {} body %body

> > dup puts! > > ) > > ; The request handler is ready, give it the name handler -> > =handler +> > :handler > > > > ; Create the parameter dictionary for the server > > {}
M site/contents/reference-io.mdsite/contents/reference-io.md

@@ -95,5 +95,5 @@ > > * At present, only the key names and sequences defined in the [nimline](https://h3rald.com/nimline/nimline.html) library are supported.

> > * At present, all the default mappings of min are those provided by the [nimline](https://h3rald.com/nimline/nimline.html) library. #} -{#op||warning||{{any}}||{{any}}|| -Prints {{any}} and a new line to STDERR, if logging level is set to [warning](class:kwd) or lower.#} +{#op||warn||{{any}}||{{any}}|| +Prints {{any}} and a new line to STDERR, if logging level is set to [warn](class:kwd) or lower.#}
M site/contents/reference-lang.mdsite/contents/reference-lang.md

@@ -145,8 +145,8 @@ > Converts {{any}} to a float value based on the following rules:

> > * If {{any}} is {{t}}, it is converted to `1.0`. > * If {{any}} is {{f}}, it is converted to `0.0`. -> * If {{any}} is {{null}}, it is converted to `0.0` ->. * If {{any}} is a integer, it is converted to float value. +> * If {{any}} is {{null}}, it is converted to `0.0`. +> * If {{any}} is a integer, it is converted to float value. > * If {{any}} is a float, no conversion is performed. > * If {{any}} is a string, it is parsed as a float value.#}

@@ -219,7 +219,7 @@ > * If {{any}} is a float, it is converted to an integer value by truncating its decimal part.

> * If {{any}} is a string, it is parsed as an integer value.#} {#op||invoke||{{sl}}||{{a0p}}|| -> Assming that {{sl}} is a formatted like *dictionary*/*symbol*, calls *symbol* defined in *dictionary* (note that this also works for nested dictionaries. +> Assuming that {{sl}} is a formatted like *dictionary*/*symbol*, calls *symbol* defined in *dictionary* (note that this also works for nested dictionaries. > > > %sidebar% > > Example

@@ -279,7 +279,7 @@ > >

> > The default logging level is _notice_.#} {#op||loglevel?||{{none}}||{{s}}|| -Returns the current log level (debug, info, notive, warn, error or fatal). #} +Returns the current log level (debug, info, notice, warn, error or fatal). #} {#op||operator||{{q}}||{{a0p}}|| > Provides a way to define a new operator (symbol, sigil, or typeclass) on the current scope performing additional checks (compared to `define` and `define-sigil`), and automatically mapping inputs and outputs.

@@ -288,14 +288,14 @@ > {{q}} is a quotation containing:

> > * A symbol identifying the type of operator to define (`symbol`, `sigil`, or `typeclass`). > * A symbol identifying the name of the operator. -> * A quotation defining the signature of the operatorm containing input and output values identified by their type and a capturing symbol, separated by the `==>` symbol. +> * A quotation defining the signature of the operator, containing input and output values identified by their type and a capturing symbol, separated by the `==>` symbol. > * A quotation identifying the body of the operator. > > The main additional features offered by this way of defining operators are the following: > > * If in development mode (`-d` or `--dev` flag specified at run time), both input and output values are checked against a type (like when using the `expect` operator *and* automatically captured in a symbol that can be referenced in the operator body quotation. > * The full signature of the operator is declared, making the resulting code easier to understand at quick glance. -> * An exception is automatically raised if the operator body pollutes the stack by adding or removing elementa from the stack (besides adding the declared output values). +> * An exception is automatically raised if the operator body pollutes the stack by adding or removing elements from the stack (besides adding the declared output values). > * It is possible to use the `return` symbol within the body quotation to immediately stop the evaluation of the body quotation and automatically push the output values on the stack. > > > %sidebar%
M site/contents/reference-stack.mdsite/contents/reference-stack.md

@@ -32,7 +32,7 @@ {#op||id||{{none}}||{{none}}||

Does nothing.#} {#op||keep||{{a1}} {{q}}||{{a0p}} {{a1}}|| -> Applies each quotation contained in the first element to each subsequent corresponding element. +> Removes the first element from the stack, dequotes it, and restores the second element. > > %sidebar% > > Example > >

@@ -61,8 +61,8 @@

{#op||set-stack||{{q}}||{{a0p}}|| Substitute the existing stack with the contents of {{q}}.#} -{#op||sip||{{a1}} ({{a2}})||{{a0p}} {{a1}}|| -Saves the {{a1}}, dequotes {{a2}}, and restores {{a1}}.#} +{#op||sip||{{q1}} {{q2}}||{{a0p}} {{q1}}|| +Saves the {{q1}}, dequotes {{q2}}, and restores {{q1}}.#} {#op||spread||{{a0p}} ({{q}}{{0p}})||{{a0p}}|| > Applies each quotation contained in the first element to each subsequent corresponding element.
M site/contents/reference-str.mdsite/contents/reference-str.md

@@ -8,8 +8,6 @@ {#alias||%||interpolate#}

{#alias||=%||apply-interpolate#} -{#alias||=~||regex#} - {#op||apply-interpolate||{{s}} {{q}}||{{s}}|| The same as pushing `apply` and then `interpolate` on the stack.#}

@@ -99,7 +97,7 @@ > >

> > `"This is a simple test. Is it really a simple test?"`#} {#op||replace-apply||{{s1}} {{s2}} {{q}}||{{s3}}|| -> Returns a copy of {{s1}} containing all occurrences of {{s2}} replaced by applying {{q}} to each quotation correponding to each match. +> Returns a copy of {{s1}} containing all occurrences of {{s2}} replaced by applying {{q}} to each quotation corresponding to each match. > > %tip% > > Tip > >

@@ -110,13 +108,13 @@ > > Example

> > > > The following: > > -> > `":1::2::3::4:" ":(\d):" (=m m 1 get :d "-$#-" (d) =%) replace-apply` +> > `":1::2::3::4:" ":(\d):" (1 get :d "-$#-" (d) =%) replace-apply` > > > > produces: > > > > `"-1--2--3--4-"` > > -> > Note that for each match the following quotations (each containing tbe full matcb and the captured matches) are produced as input for the replace quotation: +> > Note that for each match the following quotations (each containing the full match and the captured matches) are produced as input for the replace quotation: > > ("-1-" "1") > > ("-2-" "2") > > ("-3-" "3")

@@ -165,7 +163,7 @@ {#op||strip||{{sl}}||{{s}}||

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}}.#} +Returns a substring {{s2}} obtained by retrieving {{i2}} characters starting from index {{i1}} within {{s1}}.#} {#op||suffix||{{sl1}} {{sl2}}||{{s}}|| Appends {{sl2}} to {{sl1}}.#}