Compile time XML Parser?
Kaitlyn Emmons
katemmons0 at gmail.com
Wed Feb 5 02:06:58 UTC 2020
On Wednesday, 5 February 2020 at 01:51:07 UTC, Adam D. Ruppe
wrote:
> On Wednesday, 5 February 2020 at 01:43:24 UTC, Kaitlyn Emmons
> wrote:
>> Is there one in existence?
>
> Most ordinary xml D parser can run at compile time.
>
> I've tested my dom.d with it and it parses successfully, though
> several actual manipulations cause the compiler to crash [!].
>
> import arsd.dom;
>
> string translate(string xml) {
> auto document = new Document(xml, true, true);
> foreach(p; document.querySelectorAll("p"))
> p.removeAllChildren(); // this worked at least
> //p.innerText = "compile time"; // crashed!
> //p.addClass("paragraph"); // crashed!
> return document.toString();
> }
>
> // with the `enum` keyword, it runs the function at compile-time
> enum e = translate("<xml><p>cool</p></xml>");
>
> void main() {
> pragma(msg, e); // and this prints the result as it
> compiles
> }
It crash from manipulation but does it ever crash just parse and
read? I dont need manipulation, just parse and read. Going to try
parse and auto generate a VK binding from VKapi.xml that krhonos
releases :) But it is big and complex xml so need stable parser.
More information about the Digitalmars-d
mailing list