all repos — min @ 8bf2154657c0209e53cf153865a0874223de1ee9

A small but practical concatenative programming language.

No longer importing dict module.
h3rald h3rald@h3rald.com
Sat, 28 Sep 2024 22:11:34 +0200
commit

8bf2154657c0209e53cf153865a0874223de1ee9

parent

a82d0c84bcb1727bccc1f0ab1a252d7762d1d028

M minpkg/core/mmm.nimminpkg/core/mmm.nim

@@ -318,7 +318,7 @@ debug getCurrentExceptionMsg()

raiseError "Unable to install module $#@$#." % [name, version] let script = """ '$1 require :$1 -($1 'main dhas?) +($1 'main dict.has?) (*$1/main) ("Managed module \"$1\" does not expose a 'main' symbol." error) if
M minpkg/lib/min_dict.nimminpkg/lib/min_dict.nim

@@ -10,19 +10,19 @@ proc dict_module*(i: In) =

let def = i.define() - def.symbol("dhas?") do (i: In): + def.symbol("has?") do (i: In): let vals = i.expect("'sym", "dict") let k = vals[0] let d = vals[1] i.push d.dhas(k).newVal - def.symbol("dget") do (i: In): + def.symbol("get") do (i: In): let vals = i.expect("'sym", "dict") let k = vals[0] let d = vals[1] i.push i.dget(d, k) - def.symbol("dget-raw") do (i: In): + def.symbol("get-raw") do (i: In): let vals = i.expect("'sym", "dict") let k = vals[0] let d = vals[1]

@@ -34,42 +34,42 @@ i.dset(rv, "val", v)

i.dset(rv, "str", newVal($v)) i.push rv - def.symbol("dset") do (i: In): + def.symbol("set") do (i: In): let vals = i.expect("'sym", "a", "dict") let k = vals[0] let m = vals[1] var d = vals[2] i.push i.dset(d, k, m) - def.symbol("dset-sym") do (i: In): + def.symbol("set-sym") do (i: In): let vals = i.expect("'sym", "'sym", "dict") let k = vals[0] let m = newSym(vals[1].getString) var d = vals[2] i.push i.dset(d, k, m) - def.symbol("ddel") do (i: In): + def.symbol("del") do (i: In): let vals = i.expect("'sym", "dict") let k = vals[0] var d = vals[1] i.push i.ddel(d, k) - def.symbol("dkeys") do (i: In): + def.symbol("keys") do (i: In): let vals = i.expect("dict") let d = vals[0] i.push i.keys(d) - def.symbol("dvalues") do (i: In): + def.symbol("values") do (i: In): let vals = i.expect("dict") let d = vals[0] i.push i.values(d) - def.symbol("dpairs") do (i: In): + def.symbol("pairs") do (i: In): let vals = i.expect("dict") let d = vals[0] i.push i.pairs(d) - def.symbol("ddup") do (i: In): + def.symbol("dup") do (i: In): let vals = i.expect("dict") let d = vals[0] var r = newDict(i.scope)

@@ -77,7 +77,7 @@ for item in d.dVal.pairs:

r.scope.symbols[item.key] = item.val i.push r - def.symbol("dpick") do (i: In): + def.symbol("pick") do (i: In): let vals = i.expect("quot", "dict") var q = vals[0] var d = vals[1]

@@ -87,7 +87,7 @@ if d.dhas(k):

i.dset(res, k, i.dget(d, k)) i.push res - def.symbol("dtype") do (i: In): + def.symbol("type") do (i: In): let vals = i.expect("dict") i.push vals[0].objType.newVal
M next-release.mdnext-release.md

@@ -28,6 +28,19 @@ - The **time** module is no longer imported.

- **time** module: renamed **tformat** to **time.format** - **time** module: renamed **timeinfo** to **time.info** - **time** module: renamed **timestamp** to **time.stamp** +- The **dict** module is no longer imported. +- **dict** moduule: renamed **dhas?** to **dict.has?** +- **dict** moduule: renamed **dget** to **dict.get** +- **dict** moduule: renamed **dget-raw** to **dict.get-raw** +- **dict** moduule: renamed **dset** to **dict.set** +- **dict** moduule: renamed **dset-sym** to **dict.set-sym** +- **dict** moduule: renamed **ddel** to **dict.del** +- **dict** moduule: renamed **dkeys** to **dict.keys** +- **dict** moduule: renamed **dvalues** to **dict.values** +- **dict** moduule: renamed **dpairs** to **dict.pairs** +- **dict** moduule: renamed **ddup** to **dict.dup** +- **dict** moduule: renamed **dpick** to **dict.pick** +- **dict** moduule: renamed **dtype** to **dict.type**
M prelude.minprelude.min

@@ -1,5 +1,4 @@

; Imports -'dict import 'sys import 'dstore import 'crypto import
M site/contents/reference-dict.mdsite/contents/reference-dict.md

@@ -4,19 +4,19 @@ title: "dict Module"

----- {@ _defs_.md || 0 @} -{#op||ddup||{{d1}}||{{d2}}|| +{#op||dup||{{d1}}||{{d2}}|| Returns a copy of {{d1}}. #} -{#op||ddel||{{d}} {{sl}}||{{d}}|| +{#op||del||{{d}} {{sl}}||{{d}}|| Removes {{sl}} from {{d1}} and returns {{d1}}. #} -{#op||dget||{{d}} {{sl}}||{{any}}|| +{#op||get||{{d}} {{sl}}||{{any}}|| Returns the value of key {{sl}} from dictionary {{d}}. #} -{#op||dget-raw||{{d}} {{sl}}||{{rawval}}|| +{#op||get-raw||{{d}} {{sl}}||{{rawval}}|| Returns the value of key {{sl}} from dictionary {{d}}, wrapped in a {{rawval}}. #} -{#op||dhas?||{{d}} {{sl}}||{{b}}|| +{#op||has?||{{d}} {{sl}}||{{b}}|| > Returns {{t}} if dictionary {{d}} contains the key {{sl}}, {{f}} otherwise. > > > %sidebar%

@@ -27,10 +27,10 @@ > >

> > {true :a1 "aaa" :a2 false :a3} 'a2 dhas? #} -{#op||dkeys||{{d}}||({{s}}{{0p}})|| +{#op||keys||{{d}}||({{s}}{{0p}})|| Returns a quotation containing all the keys of dictionary {{d}}. #} -{#op||dpick||{{d1}} {{q}}||{{d2}}|| +{#op||pick||{{d1}} {{q}}||{{d2}}|| > Returns a new dictionary {{d2}} containing the elements of {{d1}} whose keys are included in {{q}}. > > > %sidebar%

@@ -41,7 +41,7 @@ > >

> > {5 :q 4 :a 6 :c 7 :d "d" :a} ("a" "d") dpick #} -{#op||dpairs||{{d}}||({{a0p}})|| +{#op||pairs||{{d}}||({{a0p}})|| > Returns a quotation containing a quotation for each value/key pair (value first, key second) of dictionary {{d}}. > > > %sidebar%

@@ -51,14 +51,14 @@ > > A The following program returns `((1 "a") (2 "b"))`:

> > {1 :a 2 :b} dpairs #} -{#op||dset||{{d}} {{any}} {{sl}}||{{d}}|| +{#op||set||{{d}} {{any}} {{sl}}||{{d}}|| Sets the value of the {{sl}} of {{d1}} to {{any}}, and returns the modified dictionary {{d}}. #} -{#op||dset-sym||{{d}} {{sl}} {{sl}}||{{d}}|| +{#op||set-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}}|| +{#op||type||{{d}}||{{s}}|| Returns a string set to the type of {{d}} (empty if the dictionary has no type). #} -{#op||dvalues||{{d}}||({{a0p}})|| +{#op||values||{{d}}||({{a0p}})|| Returns a quotation containing all the values of dictionary {{d}}. #}
M tasks/build.mintasks/build.min

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

-#!/usr/bin/env minsystemsystemsystem "_helpers" require :helpers 'helpers import ( symbol cz ('sym :stage 'sym :variant 'sym :target-os ==>) ( true :pack-result (stage "^(release-nopack|dev)$" match?) (false @pack-result) when "-d:release" :d-stage (stage "dev" ==) ("-d:dev" @d-stage) when " " :d-variant "min" :o-variant (variant length 0 >) ( "-d:$# " (variant) =% @d-variant "$#min" (variant) =% @o-variant ) when "nim" required "Building $# - $# (x64)" (o-variant target-os) =% io.notice! "" :musl "musl-gcc" which :musl-gcc (musl-gcc length 0 >) ("--gcc.exe:musl-gcc --gcc.linkerexe:musl-gcc" @musl) when "nim c $# -d:ssl -d:useOpenSsl3 $# --opt:size --cpu:amd64 --os:$# $#-o:$# min" (d-stage musl target-os d-variant o-variant) =% puts system stack.pop (pack-result) ( {} target-os "os" dset config "version" dget "version" dset o-variant "exe" dset pack ) when ) ) :: ;; Builds and packs a min executable. #|| Tasks ||# ( symbol guide (==>) ( "hastyscribe" required "Building - guide" io.notice! "hastyscribe Min_DeveloperGuide.md --field/version=$#" (version) =% system "cp Min_DeveloperGuide.htm site/output/guide.dev.html" system ) ) :: ;; Builds the developer guide. ( symbol site (==>) ( "hastysite" required "Building - site" io.notice! "cd site && hastysite build && cd .." system ) ) :: ;; Builds the min site. ( symbol pack (dict :vdata ==>) ( vdata "exe" dget :exe (vdata "os" dget "windows" ==) ("$#.exe" (exe) =% @exe) when "$exe:_v$version:_$os:_x64.zip" :fn fn vdata dpairs % ":" "" replace @fn "Compressing: $#" (fn) =% io.notice! (exe) => fn zip ) ) :: ;; Compresses a min executable. ( symbol vim (==>) ( config "version" dget :min-version "tasks/data/min.vim" fs.read :template timestamp "dd MMM YYYY" tformat :date min-symbols ("||" !=) filter " " join :symbols "min.vim" :out-file "Building - min.vim" io.notice! template ("date" date "version" min-version "symbols" symbols) =% out-file fs.write ) ) :: ;; Generates the min.vim file. ( symbol docs (==>) ( guide site ) ) :: ;; Generate the min development guide and site. ( symbol dev (==>) ("dev" "" os cz) ) :: ;; Builds min (dev version) on the current OS. ( symbol default (==>) ("release-nopack" "" os cz) ) :: ;; Builds min on the current OS. ( symbol linux (==>) ("" "" "linux" cz) ) :: ;; Builds min for Linux. ( symbol macosx (==>) ("" "" "macosx" cz) ) :: ;; Builds min for macOS. ( symbol windows (==>) ("" "" "windows" cz) ) :: ;; Builds min for Windows. +#!/usr/bin/env minsystemsystemsystem "_helpers" require :helpers 'helpers import ( symbol cz ('sym :stage 'sym :variant 'sym :target-os ==>) ( true :pack-result (stage "^(release-nopack|dev)$" match?) (false @pack-result) when "-d:release" :d-stage (stage "dev" ==) ("-d:dev" @d-stage) when " " :d-variant "min" :o-variant (variant length 0 >) ( "-d:$# " (variant) =% @d-variant "$#min" (variant) =% @o-variant ) when "nim" required "Building $# - $# (x64)" (o-variant target-os) =% io.notice! "" :musl "musl-gcc" which :musl-gcc (musl-gcc length 0 >) ("--gcc.exe:musl-gcc --gcc.linkerexe:musl-gcc" @musl) when "nim c $# -d:ssl -d:useOpenSsl3 $# --opt:size --cpu:amd64 --os:$# $#-o:$# min" (d-stage musl target-os d-variant o-variant) =% puts system stack.pop (pack-result) ( {} target-os "os" dict.set config "version" dict.get "version" dict.set o-variant "exe" dict.set pack ) when ) ) :: ;; Builds and packs a min executable. #|| Tasks ||# ( symbol guide (==>) ( "hastyscribe" required "Building - guide" io.notice! "hastyscribe Min_DeveloperGuide.md --field/version=$#" (version) =% system "cp Min_DeveloperGuide.htm site/output/guide.dev.html" system ) ) :: ;; Builds the developer guide. ( symbol site (==>) ( "hastysite" required "Building - site" io.notice! "cd site && hastysite build && cd .." system ) ) :: ;; Builds the min site. ( symbol pack (dict :vdata ==>) ( vdata "exe" dict.get :exe (vdata "os" dict.get "windows" ==) ("$#.exe" (exe) =% @exe) when "$exe:_v$version:_$os:_x64.zip" :fn fn vdata dict.pairs % ":" "" replace @fn "Compressing: $#" (fn) =% io.notice! (exe) => fn zip ) ) :: ;; Compresses a min executable. ( symbol vim (==>) ( config "version" dict.get :min-version "tasks/data/min.vim" fs.read :template time.stamp "dd MMM YYYY" time.format :date min-symbols ("||" !=) filter " " join :symbols "min.vim" :out-file "Building - min.vim" io.notice! template ("date" date "version" min-version "symbols" symbols) =% out-file fs.write ) ) :: ;; Generates the min.vim file. ( symbol docs (==>) ( guide site ) ) :: ;; Generate the min development guide and site. ( symbol dev (==>) ("dev" "" os cz) ) :: ;; Builds min (dev version) on the current OS. ( symbol default (==>) ("release-nopack" "" os cz) ) :: ;; Builds min on the current OS. ( symbol linux (==>) ("" "" "linux" cz) ) :: ;; Builds min for Linux. ( symbol macosx (==>) ("" "" "macosx" cz) ) :: ;; Builds min for macOS. ( symbol windows (==>) ("" "" "windows" cz) ) :: ;; Builds min for Windows.
M tasks/github.mintasks/github.min

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

-#!/usr/bin/env min "_helpers" require :helpers 'helpers import "next-release.md" fs.read escape :release-body "tasks/data/draft-release.json" fs.read :draft-release-template config "version" dget :min-version env "github-token" dget :token draft-release-template ("version" min-version "body" release-body) =% :draft-release-body {} "application/vnd.github.v3+json" "Accept" dset "token $#" (token) =% "Authorization" dset :headers ( symbol handle-errors (dict :response ==>) ( response to-json "response.json" fs.write response "status" dget :status (status 300 >) ( response "body" dget from-json :body body "message" dget :message status string @status "Error $#: $#" (status message) =% io.error status int exit ) when ) ) :: ;; Handles HTTP errors. ( symbol gh-req (dict :data ==> dict|quot :result) ( data "endpoint" dget :endpoint "api" :subdomain (data 'subdomain dhas?) (data "subdomain" dget @subdomain) when "https://$#.github.com/repos/h3rald/min$#" (subdomain endpoint) =% :url {} url "url" dset data "method" dget "method" dset (data 'headers dhas?) (data "headers" dget "headers" dset) (headers "headers" dset) if (data 'body dhas?) (data "body" dget "body" dset) when request :response response "status" dget :status response "body" dget :body response handle-errors (body length 0 >) (body from-json) ({}) if @result ) ) :: ;; Execute a request using the Github API. ( symbol get-assets (dict :data ==> quot :result) ( data "id" dget :id {} "/releases/$#/assets" (id) =% "endpoint" dset "GET" "method" dset gh-req @result ) ) :: ;; Retrieve the assets from an existing Github release. ( symbol delete-assets (dict :config ==>) ( config get-assets :assets config "id" dget :id assets ("id" dget) map :assets-ids assets-ids ( :asset {} "/releases/assets/$#" (asset) =% "endpoint" dset "DELETE" "method" dset gh-req stack.pop ) foreach ) ) :: ;; Delete all assets from an existing Github release. #|| Tasks ||# ( symbol draft (==>) ( {} "/releases" "endpoint" dset "POST" "method" dset draft-release-body "body" dset gh-req "id" dget string :id ;; Save Release ID to min.yml config id "id" dset to-yaml "min.yml" fs.write "Draft release v$# ($#) created successfully" (min-version id) =% io.notice! ) ) :: ;; Creates a new draft release on Github. ( symbol update (==>) ( config "id" dget :id {} "/releases/$#" (id) =% "endpoint" dset "PATCH" "method" dset draft-release-body "body" dset gh-req "id" dget string :id "Draft release v$# ($#) updated successfully" (min-version id) =% io.notice! ) ) :: ;; Updates the text of the current draft Github release. ( symbol assets (==>) ( config get-assets =assets assets size :total "are" :verb (total 1 ==) ("is" @verb) when "There $# $# assets in release v$#" (verb total min-version) =% io.notice! assets ("name" dget () stack.cons "- $#" stack.swap % io.notice!) foreach ) ) :: ;; Retrieve a list of all the assets of the current draft Github release. ( symbol upload (==>) ( config "id" dget :id config delete-assets pwd ls ("\\.zip$" match?) filter ( fs.filename :file "Uploading: $#" (file) =% io.notice! file fs.read :body headers "application/zip" "Content-Type" dset :asset-headers {} "/releases/$#/assets?name=$#" (id file) =% "endpoint" dset asset-headers "headers" dset "uploads" "subdomain" dset "POST" "method" dset body "body" dset gh-req stack.pop ) foreach ) ) :: ;; Uploads all assets to the current draft Github release, deleting any existing asset. +#!/usr/bin/env min "_helpers" require :helpers 'helpers import "next-release.md" fs.read escape :release-body "tasks/data/draft-release.json" fs.read :draft-release-template config "version" dict.get :min-version env "github-token" dict.get :token draft-release-template ("version" min-version "body" release-body) =% :draft-release-body {} "application/vnd.github.v3+json" "Accept" dict.set "token $#" (token) =% "Authorization" dict.set :headers ( symbol handle-errors (dict :response ==>) ( response to-json "response.json" fs.write response "status" dict.get :status (status 300 >) ( response "body" dict.get from-json :body body "message" dict.get :message status string @status "Error $#: $#" (status message) =% io.error status int exit ) when ) ) :: ;; Handles HTTP errors. ( symbol gh-req (dict :data ==> dict|quot :result) ( data "endpoint" dict.get :endpoint "api" :subdomain (data 'subdomain dict.has?) (data "subdomain" dict.get @subdomain) when "https://$#.github.com/repos/h3rald/min$#" (subdomain endpoint) =% :url {} url "url" dict.set data "method" dict.get "method" dict.set (data 'headers dict.has?) (data "headers" dict.get "headers" dict.set) (headers "headers" dict.set) if (data 'body dict.has?) (data "body" dict.get "body" dict.set) when request :response response "status" dict.get :status response "body" dict.get :body response handle-errors (body length 0 >) (body from-json) ({}) if @result ) ) :: ;; Execute a request using the Github API. ( symbol get-assets (dict :data ==> quot :result) ( data "id" dict.get :id {} "/releases/$#/assets" (id) =% "endpoint" dict.set "GET" "method" dict.set gh-req @result ) ) :: ;; Retrieve the assets from an existing Github release. ( symbol delete-assets (dict :config ==>) ( config get-assets :assets config "id" dict.get :id assets ("id" dict.get) map :assets-ids assets-ids ( :asset {} "/releases/assets/$#" (asset) =% "endpoint" dict.set "DELETE" "method" dict.set gh-req stack.pop ) foreach ) ) :: ;; Delete all assets from an existing Github release. #|| Tasks ||# ( symbol draft (==>) ( {} "/releases" "endpoint" dict.set "POST" "method" dict.set draft-release-body "body" dict.set gh-req "id" dict.get string :id ;; Save Release ID to min.yml config id "id" dict.set to-yaml "min.yml" fs.write "Draft release v$# ($#) created successfully" (min-version id) =% io.notice! ) ) :: ;; Creates a new draft release on Github. ( symbol update (==>) ( config "id" dict.get :id {} "/releases/$#" (id) =% "endpoint" dict.set "PATCH" "method" dict.set draft-release-body "body" dict.set gh-req "id" dict.get string :id "Draft release v$# ($#) updated successfully" (min-version id) =% io.notice! ) ) :: ;; Updates the text of the current draft Github release. ( symbol assets (==>) ( config get-assets =assets assets size :total "are" :verb (total 1 ==) ("is" @verb) when "There $# $# assets in release v$#" (verb total min-version) =% io.notice! assets ("name" dict.get () stack.cons "- $#" stack.swap % io.notice!) foreach ) ) :: ;; Retrieve a list of all the assets of the current draft Github release. ( symbol upload (==>) ( config "id" dict.get :id config delete-assets pwd ls ("\\.zip$" match?) filter ( fs.filename :file "Uploading: $#" (file) =% io.notice! file fs.read :body headers "application/zip" "Content-Type" dict.set :asset-headers {} "/releases/$#/assets?name=$#" (id file) =% "endpoint" dict.set asset-headers "headers" dict.set "uploads" "subdomain" dict.set "POST" "method" dict.set body "body" dict.set gh-req stack.pop ) foreach ) ) :: ;; Uploads all assets to the current draft Github release, deleting any existing asset.
M tasks/h3rald.mintasks/h3rald.min

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

-#!/usr/bin/env minsystemsystem "_helpers" require :helpers 'helpers import config "version" dget :min-version "Min_DeveloperGuide.htm" :guide-file "../h3rald/assets/min/" guide-file suffix :h3rald-guide "../h3rald/contents/min.md" :h3rald-min-md "version:\\s+\\d+\\.\\d+\\.\\d+" :min-v-reg "version: $#" (min-version) =% :min-v-rep ( symbol update (==>) ( "Updating min Developer Guide and project on H3RALD.com..." io.notice! guide-file h3rald-guide cp h3rald-min-md fs.read min-v-reg min-v-rep replace :updated-contents updated-contents h3rald-min-md fs.write "Done." io.notice! ) ) :: ;; Updates the min Developer Guide and project page on H3RALD.com ( symbol build (==>) ( "git" required "hastysite" required "Pulling content and rebuilding H3RALD.com web site..." io.notice! ;; Assuming min and h3rald are siblings parent-dir cd "h3rald" cd "git pull" system "hastysite build" system parent-dir cd "min" cd ) ) :: ;; Builds H3RALD.com web site +#!/usr/bin/env minsystemsystem "_helpers" require :helpers 'helpers import config "version" dict.get :min-version "Min_DeveloperGuide.htm" :guide-file "../h3rald/assets/min/" guide-file suffix :h3rald-guide "../h3rald/contents/min.md" :h3rald-min-md "version:\\s+\\d+\\.\\d+\\.\\d+" :min-v-reg "version: $#" (min-version) =% :min-v-rep ( symbol update (==>) ( "Updating min Developer Guide and project on H3RALD.com..." io.notice! guide-file h3rald-guide cp h3rald-min-md fs.read min-v-reg min-v-rep replace :updated-contents updated-contents h3rald-min-md fs.write "Done." io.notice! ) ) :: ;; Updates the min Developer Guide and project page on H3RALD.com ( symbol build (==>) ( "git" required "hastysite" required "Pulling content and rebuilding H3RALD.com web site..." io.notice! ;; Assuming min and h3rald are siblings parent-dir cd "h3rald" cd "git pull" system "hastysite build" system parent-dir cd "min" cd ) ) :: ;; Builds H3RALD.com web site
M tasks/help.mintasks/help.min

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

-"tasks/data/doc-snippets.json" fs.read from-json :snippets "site/contents" ls ("reference-" match?) filter :src-files "(?sm)\\{#op\\|\\|([^|]+)\\|\\|([^|]+)\\|\\|([^|]+)\\|\\|(.+?)#\\}" :op-regex "(?sm)\\{#sig\\|\\|([^|]+)\\|\\|([^#]+)#\\}" :sig-regex "(?sm)\\{#alias\\|\\|([^|]+)\\|\\|([^#]+)#\\}" :alias-regex "(?sm)\\{\\{([^}]+)\\}\\}" :snippet-regex "(?sm)\\>( \\>)*" :block-regex "(?sm)%([^%]+)%" :title-regex "(?sm)\\{@[^@]+@\\}" :incl-regex "(?sm)`([^`]+)`" :code-regex ( symbol fix-name (str :s ==> str :result) ( s "&excl;" (stack.pop "!") replace-apply "&quot;" (stack.pop "\"") replace-apply "&#124;" (stack.pop "|") replace-apply "\\[" (stack.pop "") replace-apply "\\]" (stack.pop "") replace-apply "\\(class:kwd\\)" (stack.pop "") replace-apply "&gt;" (stack.pop ">") replace-apply "&lt;" (stack.pop "<") replace-apply "&apos;" (stack.pop "'") replace-apply "&ast;" (stack.pop "*") replace-apply @result ) ) :: ;; Fixes names with special characters ( symbol process-block-markup (str :s ==> str :result) ( s block-regex (stack.pop "") replace-apply title-regex (stack.pop "") replace-apply incl-regex (stack.pop "") replace-apply code-regex (1 get) replace-apply @result ) ) :: ;; Simplify block-level markup ( symbol process-snippets (str :s ==> str :result) ( s snippet-regex ( 1 get :id snippets id dget ) replace-apply @result ) ) :: ;; Resolves documentation snippets. ( symbol process (str :s ==> str :result) ( s process-snippets process-block-markup strip @result ) ) :: ;; Processes documentation snippets and markup. ( symbol process-op (quot :matches ==> dict :data) ( {} matches 1 get process fix-name "name" dset matches 2 get process fix-name :input matches 3 get process fix-name :output "$# ==> $#" (input output) =% "signature" dset matches 4 get process "description" dset "symbol" "kind" dset @data ) ) :: ;; Processes operator reference documentation. ( symbol process-alias (quot :matches ==> dict :data) ( {} matches 1 get process fix-name "name" dset matches 2 get :ref "See $#" (ref) =% "description" dset "symbol" "kind" dset @data ) ) :: ;; Processes alias reference documentation. ( symbol process-sig (quot :matches ==> dict :data) ( {} matches 1 get process fix-name "name" dset matches 2 get :ref "See $#" (ref) =% "description" dset "sigil" "kind" dset @data ) ) :: ;; Processes sigil reference documentation. ( symbol default (==>) ( {} :ref-dict {} :op-dict {} :sig-dict src-files ( :file file "reference-([a-z]+)\\.md" search 1 get :mod-id "Processing: $#" (mod-id) =% io.notice! file fs.read :contents contents op-regex search-all ( process-op :op op "name" dget :op-name op mod-id 'module dset @op op-dict op op-name dset @op-dict ) foreach contents alias-regex search-all ( process-alias :alias alias "name" dget :alias-name alias mod-id 'module dset @alias op-dict alias alias-name dset @op-dict ) foreach contents sig-regex search-all ( process-sig :sig sig "name" dget :sig-name sig mod-id 'module dset @sig sig-dict sig sig-name dset @sig-dict ) foreach ref-dict op-dict "symbols" dset sig-dict "sigils" dset @ref-dict ) foreach "Writing help.json" io.notice! ref-dict to-json "help.json" fs.write ) ) :: ;; Builds the reference help JSON sources. +"tasks/data/doc-snippets.json" fs.read from-json :snippets "site/contents" ls ("reference-" match?) filter :src-files "(?sm)\\{#op\\|\\|([^|]+)\\|\\|([^|]+)\\|\\|([^|]+)\\|\\|(.+?)#\\}" :op-regex "(?sm)\\{#sig\\|\\|([^|]+)\\|\\|([^#]+)#\\}" :sig-regex "(?sm)\\{#alias\\|\\|([^|]+)\\|\\|([^#]+)#\\}" :alias-regex "(?sm)\\{\\{([^}]+)\\}\\}" :snippet-regex "(?sm)\\>( \\>)*" :block-regex "(?sm)%([^%]+)%" :title-regex "(?sm)\\{@[^@]+@\\}" :incl-regex "(?sm)`([^`]+)`" :code-regex ( symbol fix-name (str :s ==> str :result) ( s "&excl;" (stack.pop "!") replace-apply "&quot;" (stack.pop "\"") replace-apply "&#124;" (stack.pop "|") replace-apply "\\[" (stack.pop "") replace-apply "\\]" (stack.pop "") replace-apply "\\(class:kwd\\)" (stack.pop "") replace-apply "&gt;" (stack.pop ">") replace-apply "&lt;" (stack.pop "<") replace-apply "&apos;" (stack.pop "'") replace-apply "&ast;" (stack.pop "*") replace-apply @result ) ) :: ;; Fixes names with special characters ( symbol process-block-markup (str :s ==> str :result) ( s block-regex (stack.pop "") replace-apply title-regex (stack.pop "") replace-apply incl-regex (stack.pop "") replace-apply code-regex (1 get) replace-apply @result ) ) :: ;; Simplify block-level markup ( symbol process-snippets (str :s ==> str :result) ( s snippet-regex ( 1 get :id snippets id dict.get ) replace-apply @result ) ) :: ;; Resolves documentation snippets. ( symbol process (str :s ==> str :result) ( s process-snippets process-block-markup strip @result ) ) :: ;; Processes documentation snippets and markup. ( symbol process-op (quot :matches ==> dict :data) ( {} matches 1 get process fix-name "name" dict.set matches 2 get process fix-name :input matches 3 get process fix-name :output "$# ==> $#" (input output) =% "signature" dict.set matches 4 get process "description" dict.set "symbol" "kind" dict.set @data ) ) :: ;; Processes operator reference documentation. ( symbol process-alias (quot :matches ==> dict :data) ( {} matches 1 get process fix-name "name" dict.set matches 2 get :ref "See $#" (ref) =% "description" dict.set "symbol" "kind" dict.set @data ) ) :: ;; Processes alias reference documentation. ( symbol process-sig (quot :matches ==> dict :data) ( {} matches 1 get process fix-name "name" dict.set matches 2 get :ref "See $#" (ref) =% "description" dict.set "sigil" "kind" dict.set @data ) ) :: ;; Processes sigil reference documentation. ( symbol default (==>) ( {} :ref-dict {} :op-dict {} :sig-dict src-files ( :file file "reference-([a-z]+)\\.md" search 1 get :mod-id "Processing: $#" (mod-id) =% io.notice! file fs.read :contents contents op-regex search-all ( process-op :op op "name" dict.get :op-name op mod-id 'module dict.set @op op-dict op op-name dict.set @op-dict ) foreach contents alias-regex search-all ( process-alias :alias alias "name" dict.get :alias-name alias mod-id 'module dict.set @alias op-dict alias alias-name dict.set @op-dict ) foreach contents sig-regex search-all ( process-sig :sig sig "name" dict.get :sig-name sig mod-id 'module dict.set @sig sig-dict sig sig-name dict.set @sig-dict ) foreach ref-dict op-dict "symbols" dict.set sig-dict "sigils" dict.set @ref-dict ) foreach "Writing help.json" io.notice! ref-dict to-json "help.json" fs.write ) ) :: ;; Builds the reference help JSON sources.
M tasks/version.mintasks/version.min

@@ -5,7 +5,7 @@ "min.nimble" :nimble-cfg

"site/settings.json" :json-site-cfg yaml-cfg fs.read from-yaml :config -config "version" dget :old-version +config "version" dict.get :old-version nimble-cfg fs.read :nimble-data

@@ -13,7 +13,7 @@ (

symbol update-yaml-config ('sym :new-version ==>) ( - config new-version "version" dset @config + config new-version "version" dict.set @config config to-yaml yaml-cfg fs.write ) ) ::

@@ -24,7 +24,7 @@ symbol update-site-config

('sym :new-version ==>) ( json-site-cfg fs.read from-json :site-config - site-config new-version "version" dset @site-config + site-config new-version "version" dict.set @site-config site-config to-json json-site-cfg fs.write ) ) ::
M tests/dict.mintests/dict.min

@@ -7,47 +7,47 @@ ((("a" 1)("b" 2)("c" 3)) dictionary? not) test.assert

({1 :a 2 :b 3 :c} dictionary?) test.assert - ({1 :a 2 :b 3 :c} 'b dget 2 ==) test.assert + ({1 :a 2 :b 3 :c} 'b dict.get 2 ==) test.assert - ({1 :a 2 :b 3 :c} :dict1 dict1 5 'b dset 7 "d" dset :newdict newdict {1 :a 5 :b 3 :c 7 :d} == dict1 newdict != and) test.assert + ({1 :a 2 :b 3 :c} :dict1 dict1 5 'b dict.set 7 "d" dict.set :newdict newdict {1 :a 5 :b 3 :c 7 :d} == dict1 newdict != and) test.assert - ({1 :a 2 :b 3 :c} :dict1 dict1 ddup 5 'b dset 7 "d" dset :newdict newdict {1 :a 5 :b 3 :c 7 :d} == dict1 {1 :a 2 :b 3 :c} == and) test.assert + ({1 :a 2 :b 3 :c} :dict1 dict1 dict.dup 5 'b dict.set 7 "d" dict.set :newdict newdict {1 :a 5 :b 3 :c 7 :d} == dict1 {1 :a 2 :b 3 :c} == and) test.assert - ({1 :a 2 :b 3 :c} :dict1 dict1 'b ddel {1 :a 3 :c} ==) test.assert + ({1 :a 2 :b 3 :c} :dict1 dict1 'b dict.del {1 :a 3 :c} ==) test.assert - ({1 :a 2 :b 3 :c} dkeys ("a" "b" "c") ==) test.assert + ({1 :a 2 :b 3 :c} dict.keys ("a" "b" "c") ==) test.assert - ({1 :a 2 :b 3 :c} dvalues (1 2 3) ==) test.assert + ({1 :a 2 :b 3 :c} dict.values (1 2 3) ==) test.assert - (global dtype "module" ==) test.assert + (global dict.type "module" ==) test.assert - ({} dtype "" ==) test.assert + ({} dict.type "" ==) test.assert - ({1 :a 2 :b 3 :c 4 :d} ("b" "c") dpick {2 :b 3 :c} ==) test.assert + ({1 :a 2 :b 3 :c 4 :d} ("b" "c") dict.pick {2 :b 3 :c} ==) test.assert - (2 2 {+ :plus} "plus" dget 4 ==) test.assert + (2 2 {+ :plus} "plus" dict.get 4 ==) test.assert - (2 {(2 3 +) :sum} "sum" dget -> + 7 ==) test.assert + (2 {(2 3 +) :sum} "sum" dict.get -> + 7 ==) test.assert - ({a :test} "test" dget-raw "str" dget "a" ==) test.assert + ({a :test} "test" dict.get-raw "str" dict.get "a" ==) test.assert - ({} 'aaa 'test dset-sym {aaa :test} ==) test.assert + ({} 'aaa 'test dict.set-sym {aaa :test} ==) test.assert ( {} :archives ({"a" :a 2 :b} {"aa" :a 4 :b} {"aaa" :a 6 :b}) ( :article - article "a" dget :code + article "a" dict.get :code {} - code "code" dset + code "code" dict.set :archive - archives archive code dset @archives + archives archive code dict.set @archives ) foreach archives {{"a" :code} :a {"aa" :code} :aa {"aaa" :code} :aaa} ==) test.assert ( - {1 :a 2 :b 3 :c} dpairs ((1 "a") (2 "b") (3 "c")) == + {1 :a 2 :b 3 :c} dict.pairs ((1 "a") (2 "b") (3 "c")) == ) test.assert test.report
M tests/dstore.mintests/dstore.min

@@ -9,8 +9,8 @@ (

"dstore.json" dsread :ds ds "tests" {} - 1 "test1" dset - 2 "test2" dset + 1 "test1" dict.set + 2 "test2" dict.set dspost dswrite "tests" (stack.pop true) dsquery size 1 == ) test.assert

@@ -19,16 +19,16 @@ (

"dstore.json" dsread :ds ds "tests/aaa" {} - 1 "test1" dset - 3 "test3" dset + 1 "test1" dict.set + 3 "test3" dict.set dsput dswrite - "tests" ("test1" dget 1 ==) dsquery size 2 == + "tests" ("test1" dict.get 1 ==) dsquery size 2 == ) test.assert ( "dstore.json" dsread :ds ds "tests/aaa" dsdelete - "tests" ("id" dget "aaa" ==) dsquery size 0 == + "tests" ("id" dict.get "aaa" ==) dsquery size 0 == ) test.assert "dstore.json" rm
M tests/fs.mintests/fs.min

@@ -12,7 +12,7 @@ ("test.txt" fs.type "file" ==) test.assert

("test.txt" fs.hidden? false ==) test.assert - ("test.txt" fs.stats 'type dget "file" ==) test.assert + ("test.txt" fs.stats 'type dict.get "file" ==) test.assert ("tests" fs.dir?) test.assert
M tests/global.mintests/global.min

@@ -69,7 +69,7 @@

( ( (stack.pop) - ('error dget) + ('error dict.get) ("finally") ) try stack.get ("MinEmptyStackError" "finally") ==) test.assert

@@ -87,7 +87,7 @@

( ( ({"TestError" :error "Test Message" :message} raise) - ("error" dget) + ("error" dict.get) ) try "TestError" ==) test.assert (

@@ -170,8 +170,8 @@ ("3.678" float 3.678 ==) test.assert

( {1 :a 2 :b 3 :c} ( - (stack.dup "a" dget succ succ "a" dset) - (stack.dup "b" dget succ "b" dset) + (stack.dup "a" dict.get succ succ "a" dict.set) + (stack.dup "b" dict.get succ "b" dict.set) ) tap {3 :a 3 :b 3 :c} == ) test.assert

@@ -179,8 +179,8 @@

( {} :data data ( - 1 "a" dset - 2 "b" dset + 1 "a" dict.set + 2 "b" dict.set ) tap {1 :a 2 :b} == ) test.assert

@@ -293,7 +293,7 @@ constructor test-c

(str :in ==> dict :out) ( {} - in "test" dset + in "test" dict.set @out ) ) ::

@@ -735,7 +735,7 @@ (0 (1 2 3) prepend (0 1 2 3) ==) test.assert

((1 2 3 4) 2 get 3 ==) test.assert - ((a b c) 1 get-raw "type" dget "sym" ==) test.assert + ((a b c) 1 get-raw "type" dict.get "sym" ==) test.assert ((1 2 3 4) 222 2 set (1 2 222 4) ==) test.assert
M tests/http.mintests/http.min

@@ -6,54 +6,54 @@

"postman-echo.com" :host "https://$1" (host) => % :url - ("$1/get" (url) => % get-content from-json "headers" dget "user-agent" dget "min http-module/$1" (version) => % ==) test.assert + ("$1/get" (url) => % get-content from-json "headers" dict.get "user-agent" dict.get "min http-module/$1" (version) => % ==) test.assert - ("$1/get?test=Hello!" (url) => % "tests/test1.json" :file file download file fs.read from-json "args" dget "test" dget "Hello!" ==) test.assert + ("$1/get?test=Hello!" (url) => % "tests/test1.json" :file file download file fs.read from-json "args" dict.get "test" dict.get "Hello!" ==) test.assert "tests/test1.json" rm ( {} ( - ("$1/get" (url) => % "url" dset) - ("GET" "method" dset) - ({"it-it" :Accept-Language} "headers" dset) + ("$1/get" (url) => % "url" dict.set) + ("GET" "method" dict.set) + ({"it-it" :Accept-Language} "headers" dict.set) (request) - ) tap "body" dget from-json "headers" dget "accept-language" dget "it-it" == + ) tap "body" dict.get from-json "headers" dict.get "accept-language" dict.get "it-it" == ) test.assert ( {} ( - ("$1/put" (url) => % "url" dset) - ("PUT" "method" dset) - ({} to-json "body" dset) + ("$1/put" (url) => % "url" dict.set) + ("PUT" "method" dict.set) + ({} to-json "body" dict.set) (request) - ) tap "body" dget from-json "data" dget {} == + ) tap "body" dict.get from-json "data" dict.get {} == ) test.assert ( {} ( - ("$1/post" (url) => % "url" dset) - ("POST" "method" dset) - ({"post" :test} to-json "body" dset) + ("$1/post" (url) => % "url" dict.set) + ("POST" "method" dict.set) + ({"post" :test} to-json "body" dict.set) (request) - ) tap "headers" dget "content-type" dget "^application/json" match? + ) tap "headers" dict.get "content-type" dict.get "^application/json" match? ) test.assert ( {} ( - ("$1/patch" (url) => % "url" dset) - ("PATCH" "method" dset) - ({} to-json "body" dset) + ("$1/patch" (url) => % "url" dict.set) + ("PATCH" "method" dict.set) + ({} to-json "body" dict.set) (request) - ) tap "body" dget from-json "data" dget {} == + ) tap "body" dict.get from-json "data" dict.get {} == ) test.assert ( {} ( - ("$1/delete" (url) => % "url" dset) - ("DELETE" "method" dset) + ("$1/delete" (url) => % "url" dict.set) + ("DELETE" "method" dict.set) (request) - ) tap "body" dget from-json "url" dget "https?:\\/\\/$1/delete" (host) => % match? + ) tap "body" dict.get from-json "url" dict.get "https?:\\/\\/$1/delete" (host) => % match? ) test.assert test.report
M tests/sys.mintests/sys.min

@@ -30,7 +30,7 @@

("systest" cd pwd "systest" match?) test.assert parent-dir cd - ("./min -v" run 'output dget "\\." match?) test.assert + ("./min -v" run 'output dict.get "\\." match?) test.assert ("PATH" env?) test.assert

@@ -63,7 +63,7 @@ parent-dir cd

("systest" rmdir pwd ls (pwd "systest") => "/" join in? false ==) test.assert - ([ls] "ls" run "output" dget ==) test.assert + ([ls] "ls" run "output" dict.get ==) test.assert test.report stack.clear
M tests/time.mintests/time.min

@@ -13,9 +13,9 @@ (1464951736 "yy-MM-dd" time.format "16-06-03" ==) test.assert

(1464951736 time.info time.to-timestamp 1464951736 ==) test.assert - (1464951736 time.info 'second dget 16 ==) test.assert + (1464951736 time.info 'second dict.get 16 ==) test.assert - (1464951736 time.info 'timezone dget integer?) test.assert + (1464951736 time.info 'timezone dict.get integer?) test.assert test.report stack.clear
M tests/xml.mintests/xml.min

@@ -4,29 +4,29 @@

"xml" test.describe - ("test" xentity "text" dget "test" ==) test.assert + ("test" xentity "text" dict.get "test" ==) test.assert - ("test" xcomment "text" dget "test" ==) test.assert + ("test" xcomment "text" dict.get "test" ==) test.assert - ("test" xtext "text" dget "test" ==) test.assert + ("test" xtext "text" dict.get "test" ==) test.assert - ("test" xcdata "text" dget "test" ==) test.assert + ("test" xcdata "text" dict.get "test" ==) test.assert - ("test" xelement "tag" dget "test" ==) test.assert + ("test" xelement "tag" dict.get "test" ==) test.assert ( "test" xelement :xnode - xnode {"a" :attr1} "attributes" dset @xnode + xnode {"a" :attr1} "attributes" dict.set @xnode "a1" xelement :child "text..." xtext :text - xnode (child text) => "children" dset @xnode + xnode (child text) => "children" dict.set @xnode xnode to-xml "<test attr1=\"a\"><a1 />text...</test>" == ) test.assert ( "<ul><li class='test'>yes</li><li class='test'>...</li><li>no</li></ul>" from-xml :xnode xnode "li.test" xquery - "children" dget first "text" dget "yes" == + "children" dict.get first "text" dict.get "yes" == ) test.assert (