all repos — min @ 99dcee2e98aae426ba47c68b2967ad49644c853e

A small but practical concatenative programming language.

Fixes
h3rald h3rald@h3rald.com
Sat, 23 Jan 2021 22:10:53 +0100
commit

99dcee2e98aae426ba47c68b2967ad49644c853e

parent

f81d151c5e8ae4c9c6ff0059fedc172ee331d407

M build_mintoolbuild_mintool

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

-min -c -m:tasks -a:tasks/data -n:'-d:release' mintool +min -c -m:tasks -a:tasks/data -n:'-d:release -d:ssl --opt:size' mintool
M minpkg/core/utils.nimminpkg/core/utils.nim

@@ -5,13 +5,10 @@ import

baseutils, parser, value, + json, scope, interpreter -when not defined(mini): - import - json - # Library methods proc define*(i: In): ref MinScope =

@@ -120,59 +117,57 @@ r.add key.newVal

r.add value.val return r.newVal -when not defined(mini): - # JSON interop - proc `%`*(i: In, a: MinValue): JsonNode = - case a.kind: - of minBool: - return %a.boolVal - of minNull: - return newJNull() - of minSymbol: - return %(";sym:$1" % [a.getstring]) - of minString: - return %a.strVal - of minInt: - return %a.intVal - of minFloat: - return %a.floatVal - of minQuotation: - result = newJArray() - for it in a.qVal: - result.add(i%it) - of minDictionary: - result = newJObject() - for it in a.dVal.pairs: - result[it.key] = i%i.dget(a, it.key) +proc `%`*(i: In, a: MinValue): JsonNode = + case a.kind: + of minBool: + return %a.boolVal + of minNull: + return newJNull() + of minSymbol: + return %(";sym:$1" % [a.getstring]) + of minString: + return %a.strVal + of minInt: + return %a.intVal + of minFloat: + return %a.floatVal + of minQuotation: + result = newJArray() + for it in a.qVal: + result.add(i%it) + of minDictionary: + result = newJObject() + for it in a.dVal.pairs: + result[it.key] = i%i.dget(a, it.key) - proc fromJson*(i: In, json: JsonNode): MinValue = - case json.kind: - of JNull: - result = newNull() - of JBool: - result = json.getBool.newVal - of JInt: - result = json.getBiggestInt.newVal - of JFloat: - result = json.getFloat.newVal - of JString: - let s = json.getStr - if s.startsWith(";sym:"): - result = s.replace(";sym:", "").newSym - else: - result = json.getStr.newVal - of JObject: - var res = newDict(i.scope) - for key, value in json.pairs: - discard i.dset(res, key, i.fromJson(value)) - return res - of JArray: - var res = newSeq[MinValue](0) - for value in json.items: - res.add i.fromJson(value) - return res.newVal +proc fromJson*(i: In, json: JsonNode): MinValue = + case json.kind: + of JNull: + result = newNull() + of JBool: + result = json.getBool.newVal + of JInt: + result = json.getBiggestInt.newVal + of JFloat: + result = json.getFloat.newVal + of JString: + let s = json.getStr + if s.startsWith(";sym:"): + result = s.replace(";sym:", "").newSym + else: + result = json.getStr.newVal + of JObject: + var res = newDict(i.scope) + for key, value in json.pairs: + discard i.dset(res, key, i.fromJson(value)) + return res + of JArray: + var res = newSeq[MinValue](0) + for value in json.items: + res.add i.fromJson(value) + return res.newVal # Validators
M minpkg/lib/min_lang.nimminpkg/lib/min_lang.nim

@@ -2,6 +2,7 @@ import

critbits, strutils, sequtils, + json, parseopt, algorithm when defined(mini):

@@ -11,7 +12,6 @@ ../core/minilogger

else: import os, - json, logging, ../core/baseutils, ../packages/niftylogger,

@@ -28,11 +28,11 @@ ../core/scope

proc lang_module*(i: In) = let def = i.scope + + const HELPFILE = "../../help.json".slurp + let HELP = HELPFILE.parseJson when not defined(mini): - - const HELPFILE = "../../help.json".slurp - let HELP = HELPFILE.parseJson def.symbol("from-json") do (i: In): let vals = i.expect("string")

@@ -550,7 +550,7 @@ var doc = i.fromJson(sym.doc)

doc.objType = "help" i.push doc return - elif not defined(mini) and HELP["operators"].hasKey(s): + elif HELP["operators"].hasKey(s): var doc = i.fromJson(HELP["operators"][s]) doc.objType = "help" i.push doc

@@ -567,7 +567,7 @@ var doc = i.fromJson(sym.doc)

doc.objType = "help" i.push doc return - elif not defined(mini) and HELP["operators"].hasKey(s): + elif HELP["operators"].hasKey(s): var doc =i.fromJson(HELP["operators"][s]) doc.objType = "help" i.push doc

@@ -598,7 +598,7 @@ let sym = i.scope.getSymbol(s)

if not sym.doc.isNil and sym.doc.kind == JObject: foundDoc = true displayDoc(sym.doc) - elif not defined(mini) and HELP["operators"].hasKey(s): + elif HELP["operators"].hasKey(s): foundDoc = true displayDoc HELP["operators"][s] if i.scope.hasSigil(s):

@@ -607,7 +607,7 @@ let sym = i.scope.getSigil(s)

if not sym.doc.isNil and sym.doc.kind == JObject: foundDoc = true displayDoc(sym.doc) - elif not defined(mini) and HELP["sigils"].hasKey(s): + elif HELP["sigils"].hasKey(s): foundDoc = true displayDoc HELP["sigils"][s] if not found:
M site/settings.jsonsite/settings.json

@@ -6,9 +6,5 @@ "rules": "rules.min",

"temp": "temp", "templates": "templates", "title": "min language", -<<<<<<< HEAD "version": "0.30.0" -======= - "version": "0.29.1" ->>>>>>> master -}+}
M tasks/build.mintasks/build.min

@@ -55,7 +55,7 @@ (==>)

( "hastysite" required "Building - site" notice! - !!"cd site && hastysite build && cd .." + "cd site && hastysite build && cd .." !! ) ) :: ;; Builds the min site.

@@ -139,7 +139,7 @@ ;; Builds litemin for Linux.

( symbol linux-mini (==>) - ("" "" "linux-mini" cz) + ("" "mini" "linux" cz) ) :: ;; Builds minimin for Linux. (

@@ -157,7 +157,7 @@ ;; Builds litemin for macOS.

( symbol macosx-mini (==>) - ("" "" "macosx-mini" cz) + ("" "mini" "macosx" cz) ) :: ;; Builds minimin for macOS. (

@@ -175,6 +175,6 @@ ;; Builds litemin for Windows.

( symbol windows-mini (==>) - ("" "" "windows-mini" cz) + ("" "mini" "windows" cz) ) :: ;; Builds minimin for Windows.
M tasks/github.mintasks/github.min

@@ -32,7 +32,7 @@ ;; Handles HTTP errors.

( symbol gh-req - (dict :data ==> dict :result) + (dict :data ==> dict|quot :result) ( data /endpoint :endpoint "api" :subdomain

@@ -50,27 +50,31 @@ request :response

response /status :status response /body :body response handle-errors - (body length 0 >) (body from-json) ({}) if @result + (body length 0 >) (body from-json) ({}) if + (quotation?) + (#result) + (@result) + if ) ) :: ;; Execute a request using the Github API. ( symbol get-assets - (dict :data ==> dict :result) + (dict :data ==> quot :result) ( data /id :id {} "/releases/$#/assets" (id) =% %endpoint "GET" %method - gh-req @result + gh-req #result ) ) :: ;; Retrieve the assets from an existing Github release. ( symbol delete-assets - (==>) + (dict :config ==>) ( config get-assets =assets config /id :id