Phantasmal MUD Lib for DGD
Phantasmal Site > Phantasmal Operation > UNQ Files UNQ Files: What Are They?UNQ is a format for structured data storage. It's a lot like XML, though it's got some advantages for our use that XML doesn't. Specifically, there are some features that XML has that makes it difficult to use and to parse. Skotos solves this problem by just not implementing most of the problem features in their XML parser. Phantasmal solves it by using something other than XML. That something is called UNQ, which was invented by Tom Lokovic as the basis of a language called PLUNQ. We don't use PLUNQ in Phantasmal, but we do use UNQ. Clear as mud? So what's different from XML? Well, an XML/HTML fragment like What's <i>up</i>, doc? would become What's ~i{up}, doc? in UNQ. Note that a tagged fragment starts with a tilde, then what the tag is (also called the label — in this case, "i"), and then has the content in curly braces. Like HTML and XML, UNQ embeds nicely in itself. So an HTML expression like <body> Content goes <b>here</b> </body> would become ~body{ Content goes ~b{here} } in UNQ. Unlike in HTML, you can just skip the label. So, for instance, {{Fred}{25}}{{Ethel}{39}} is a perfectly good UNQ expression. The equivalent XML would have a lot of empty tags (like, tags that had no name, written something like <>) and look awful. UNQ pays attention to whitespace, so ~bob{spam} and ~bob { spam } are quite different from each other. That's not to say that every application of UNQ will treat the two differently — for instance, Phantasmal help files don't. But some UNQ files may treat the two as different. Beware. Even newlines can be permitted, both in text and in labels. So what are the big differences from XML? First off, UNQ has none of the extra little quoted things inside tags. Non-tagged stuff translates fine. But an HTML fragment like <h3 align="center"> My Title </h3> doesn't translate at all. There's no equivalent in UNQ to bits like the align="center". UNQ does nothing like that (nor, if memory serves, does Skotos' XML). Getting rid of that makes the files easier to read that HTML or XML, and makes it easier for the MUD to parse them. In HTML, there are characters like the less-than and greater-than signs that start tags. If you want to put a special character in your HTML document, you need to write it as something like < or " or &. What's the UNQ equivalent? How do you write a curly-brace in UNQ, or a tilde? UNQ, like C and LPC, uses a method called backslash-escaping for this purpose. To write a tilde, you put \~ (backslash, then tilde) into your UNQ file. You put the backslash in front of any curly brace (open or closed), any tilde, and any backslash that you want to have appear literally in your document. For instance, a valid piece of UNQ might be my data contains a \~. You can't write my document contains a ~ — it's not valid UNQ, because it looks like you tried to make an UNQ tag and then never got around to putting curly braces. |