all repos — min @ 25a958f3c3158b53a3dd64da7a18e489d9454735

A small but practical concatenative programming language.

Started working on integrated reference docs
h3rald h3rald@h3rald.com
Fri, 22 Jan 2021 20:35:14 +0100
commit

25a958f3c3158b53a3dd64da7a18e489d9454735

parent

181eb34f3ceeb5c0407a026fc43c11d2d778e1d0

4 files changed, 142 insertions(+), 60 deletions(-)

jump to
D help/defs.yml

@@ -1,59 +0,0 @@

-q: quot -q1: quot1 -q2: quot2 -q3: quot3 -q4: quot4 -1: 1 -2: 2 -3: 3 -4: 4 -e: dict:error -tinfo: dict:timeinfo -dstore: dict:datastore -d: dict -d1: dict1 -d2: dict2 -d0p: dict* -flt: float -i: int -i1: int1 -i2: int2 -i3: int3 -n: num -n1: num1 -n2: num2 -n3: num3 -any: a -a1: a1 -a2: a2 -a3: a3 -a0p: a* -s0p: string* -s: string -s1: string1 -s2: string2 -s3: string3 -s4: string4 -b: bool -b1: bool1 -b2: bool2 -b3: bool3 -01: ? -0p: * -1p: + -sl: 'sym -sl1: 'sym1 -sl2: 'sym2 -f: false -t: true -null: null -none: -help: dict:help -sock: dict:socket -url: url -req: request -res: response -sock1: dict:socket1 -sock2: dict:socket2 -m: min -sgregex: sgregex
A help/snippets.json

@@ -0,0 +1,61 @@

+{ + "1": "1", + "2": "2", + "3": "3", + "4": "4", + "q": "quot", + "q1": "quot1", + "q2": "quot2", + "q3": "quot3", + "q4": "quot4", + "e": "dict:error", + "tinfo": "dict:timeinfo", + "dstore": "dict:datastore", + "d": "dict", + "d1": "dict1", + "d2": "dict2", + "d0p": "dict*", + "flt": "float", + "i": "int", + "i1": "int1", + "i2": "int2", + "i3": "int3", + "n": "num", + "n1": "num1", + "n2": "num2", + "n3": "num3", + "any": "a", + "a1": "a1", + "a2": "a2", + "a3": "a3", + "a0p": "a*", + "s0p": "string*", + "s": "string", + "s1": "string1", + "s2": "string2", + "s3": "string3", + "s4": "string4", + "b": "bool", + "b1": "bool1", + "b2": "bool2", + "b3": "bool3", + "01": "?", + "0p": "*", + "1p": "+", + "sl": "'sym", + "sl1": "'sym1", + "sl2": "'sym2", + "f": "false ", + "t": "true", + "null": "null", + "none": "", + "help": "dict:help", + "sock": "dict:socket", + "url": "url", + "req": "request", + "res": "response", + "sock1": "dict:socket1", + "sock2": "dict:socket2", + "m": "min", + "sgregex": "sgregex" + }
M minpkg/lib/min_str.nimminpkg/lib/min_str.nim

@@ -150,7 +150,7 @@ def.symbol("search") do (i: In):

let vals = i.expect("string", "string") let reg = vals[0] let str = vals[1] - var matches = str.strVal.search(reg.strVal) + var matches = str.strVal.search(reg.strVal, "m") var res = newSeq[MinValue](matches.len) for i in 0..matches.len-1: res[i] = matches[i].newVal

@@ -164,6 +164,19 @@ if str.strVal.match(reg.strVal):

i.push true.newVal else: i.push false.newVal + + def.symbol("search-all") do (i: In): + let vals = i.expect("string", "string") + var res = newSeq[MinValue](0) + let reg = vals[0].strVal + let str = vals[1].strVal + let rawMatches = str.searchAll(reg, "m") + for m in rawMatches: + var matches = newSeq[MinValue](0) + for capture in m: + matches.add capture.newVal + res.add matches.newVal + i.push res.newVal def.symbol("replace-apply") do (i: In): let vals = i.expect("quot", "string", "string")
A tasks/help.min

@@ -0,0 +1,67 @@

+"help/snippets.json" fread from-json :snippets +"site/contents" ls ("reference-" match) filter =src-files +"/\\{\\#op\\|\\|([^|]+)\\|\\|([^|]+)\|\|([^|]+)\|\|([^#])+\\#\\}/g" :op-regex +"\\{\\{([^}]+)\\}\\}" :snippet-regex +"^>( >)*" :block-regex +"%([^%]+)%" :title-regex + +( + symbol process-block-markup + (string :s ==> string :result) + ( + s + block-regex (pop "") replace-apply + title-regex (1 get titleize) replace-apply + @result + ) +) :: +;; Simplify block-level markup + +( + symbol process-snippets + (string :s ==> string :result) + ( + s snippet-regex ( + 1 get :id + snippets id dget + ) replace-apply @result + ) +) :: +;; Resolves documentation snippets. + +( + symbol process + (string :s ==> string :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 %name + matches 2 get process %input + matches 3 get process %output + matches 4 get process %description + @data + ) +) :: +;; Processes operator reference documentation. + +( + symbol default + (==>) + ( + src-files ( + fread op-regex search-all puts ( + puts process-op :op + op puts! + ) foreach + ) foreach + ) +) :: +;; Builds the reference help JSON sources.