all repos — min @ 1f3038be2d85cc9135045711e04745d0be6263a5

A small but practical concatenative programming language.

Implemented xml module
h3rald h3rald@h3rald.com
Sun, 30 Jul 2023 09:34:36 +0000
commit

1f3038be2d85cc9135045711e04745d0be6263a5

parent

619786cba53b9945338acd228a0aacb61a76fd40

3 files changed, 23 insertions(+), 9 deletions(-)

jump to
M min.nimmin.nim

@@ -28,6 +28,7 @@ minpkg/lib/min_sys,

minpkg/lib/min_io, minpkg/lib/min_dstore, minpkg/lib/min_fs, + minpkg/lib/min_xml, minpkg/lib/min_http, minpkg/lib/min_net, minpkg/lib/min_crypto,

@@ -149,6 +150,7 @@ i.crypto_module

i.net_module i.math_module i.http_module + i.xml_module if customPrelude == "": i.eval PRELUDE, "<prelude>" else:
M minpkg/lib/min_xml.nimminpkg/lib/min_xml.nim

@@ -13,7 +13,7 @@ ../core/interpreter,

../core/utils -let xmltypes = "dict:xml-text|dict:xml-verbatim-text|xml-element|xml-cdata|xml-comment" +let xmltypes = "dict:xml-text|dict:xml-verbatim-text|dict:xml-element|dict:xml-cdata|dict:xml-comment|dict:xml-entity" proc newXDict(i: In, xml: XmlNode): MinValue = result = newDict(i.scope)

@@ -123,5 +123,16 @@ let xdict = vals[0]

let query = vals[1].getString let root = i.newXml(xdict) i.push i.newXDict(root.querySelector(query)) + + def.symbol("xqueryall") do (i: In): + let vals = i.expect("dict:xml-element", "'sym") + let xdict = vals[0] + let query = vals[1].getString + let root = i.newXml(xdict) + let xresults = root.querySelectorAll(query) + var results = newSeq[MinValue](0) + for e in xresults: + results.add i.newXDict(e) + i.push results.newVal def.finalize("xml")
M prelude.minprelude.min

@@ -6,13 +6,14 @@ 'stack import

'seq import 'dict import 'time import -'io import -'fs import -'sys import -'dstore import -'crypto import -'math import -'net import -'http import +'io import +'fs import +'sys import +'dstore import +'crypto import +'math import +'net import +'http import +'xml import ; Unseal prompt symbol 'prompt unseal-symbol