all repos — min @ bdc7fbb2a08c47a7c041e9cb34f08204e7831dee

A small but practical concatenative programming language.

Added semver? symbol, added version task.
h3rald h3rald@h3rald.com
Sat, 05 Dec 2020 14:31:36 +0100
commit

bdc7fbb2a08c47a7c041e9cb34f08204e7831dee

parent

8d122c6a72157b956b9e838ae7f415b9f4f90528

M core/interpreter.nimcore/interpreter.nim

@@ -301,7 +301,6 @@ contents = ";;\n" & fileLines[1..fileLines.len-1].join("\n")

else: contents = fileLines.join("\n") var i2 = i.copy(s) - echo contents i2.open(newStringStream(contents), s) discard i2.parser.getToken() result = i2.interpret(parseOnly)
M lib/min_lang.nimlib/min_lang.nim

@@ -82,7 +82,7 @@ let lines = s.strVal.split("\n")

for line in lines: let pair = line.split(":") i.dset(dict, pair[0].strip, pair[1].strip.newVal) - i.push(dict) + i.push(dict) except: raiseInvalid("Invalid/unsupported YAML object (only dictionaries with string values are supported)")
M lib/min_str.nimlib/min_str.nim

@@ -150,6 +150,11 @@ var res = newSeq[MinValue](0)

for r in results: res.add(r.newVal) i.push res.newVal + + def.symbol("semver?") do (i: In): + let vals = i.expect("string") + let v = vals[0].strVal + i.push v.match("^\\d+\\.\\d+\\.\\d+$").newVal def.symbol("from-semver") do (i: In): let vals = i.expect("string")
M min.ymlmin.yml

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

-name: min -version: 0.22.0 author: Fabio Cevasco -description: A tiny concatenative programming language and shell.+description: A tiny concatenative programming language and shell. +name: min +version: 0.23.0
M site/contents/reference-str.mdsite/contents/reference-str.md

@@ -158,6 +158,9 @@

{#op||semver-inc-patch||{{s1}}||{{s2}}|| Increments the patch digit of the [SemVer](https://semver.org)-compliant string (with no additional labels) {{s1}}. #} +{#op||semver?||{{s}}||{{b}}|| +Checks whether {{s}} is a [SemVer](https://semver.org)-compliant version or not. #} + {#op||split||{{sl1}} {{sl2}}||{{q}}|| Splits {{sl1}} using separator {{sl2}} and returns the resulting strings within the quotation {{q}}. #}
M site/settings.jsonsite/settings.json

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

{ - "contents": "contents", "assets": "assets", - "templates": "templates", - "temp": "temp", + "contents": "contents", "output": "output", + "rules": "rules.min", + "temp": "temp", + "templates": "templates", "title": "min language", - "version": "0.22.0", - "rules": "rules.min" -} + "version": "0.23.0" +}
A tasks/version.min

@@ -0,0 +1,48 @@

+#!/usr/bin/env min + +"min.yml" :yaml-cfg +"site/settings.json" :json-site-cfg + +yaml-cfg fread from-yaml :config +config /version :old-version +( + :new-version + config new-version %version @config + config to-yaml yaml-cfg fwrite +) :update-yaml-config +( + :new-version + json-site-cfg fread from-json :site-config + site-config new-version %version @site-config + site-config to-json json-site-cfg fwrite +) :update-site-config + +; Module tasks +{} +( + "" :new-version + false :valid-semver + (valid-semver not) + ( + "New version" ask @new-version + new-version semver? @valid-semver + ) while + new-version update-yaml-config + new-version update-site-config +) %set +( + old-version semver-inc-major :new-version + new-version update-yaml-config + new-version update-site-config +) %major +( + old-version semver-inc-minor :new-version + new-version update-yaml-config + new-version update-site-config +) %minor +( + old-version semver-inc-patch :new-version + new-version update-yaml-config + new-version update-site-config +) %patch ++version-tasks