Lucretiel / kaydle

An alternative implementation of Kat's Document Language, including serde integration
Mozilla Public License 2.0
74 stars 4 forks source link

panic on TypeNameMismatch #14

Closed taikulawo closed 2 months ago

taikulawo commented 2 months ago

I'm trying parse follow txt, but get

called `Result::unwrap()` on an `Err` value: TypeNameMismatch { node_name: "server_name", type_name: "ServerBlock" }

reproduce text

worker_processes  1
events {
    worker_connections  1024
}

http {
    include       "mime.types"
    server {
        server_name  "localhost"
        location "/" {
            root   "html"
            index  "index.html" "index.htm"
        }
        location "/" {
            root   "html"
            index  "index.html" "index.htm"
        }

    }
    server {
        server_name  "localhost"
        location "/" {
            root   "html"
            index  "index.html" "index.htm"
        }
        location "/" {
            root   "html"
            index  "index.html" "index.htm"
        }

    }

}
taikulawo commented 2 months ago

here are repo https://github.com/taikulawo/languages/blob/master/rust/src/bin/kdl.rs

Lucretiel commented 2 months ago

I'm not sure if there's yet a good way in kaydle to handle lists of sibling nodes like this— each set of children is modeled either as a uniformly typed list of nodes, or as a record containing node names. Figuring out how to model something resembling include: String, server: Vec<Server> is on my long term roadmap (though I suspect it may not be possible to make this compatible with the serde model).

taikulawo commented 2 months ago

Ok, I got it. I use kdl-rs to do it manually. thank you :)