[DGD] Phantasmal's UNQ system.

Noah Gibbs noah_gibbs at yahoo.com
Thu Aug 9 01:38:02 CEST 2007


  I'll assume in my reply that you're planning to use Phantasmal's "UNQable"
library and parser.  The interface might be different if you implemented it
differently.

  The UNQable type allows you to export UNQ either in list/tree format, or as
text.  You have your object inherit from UNQable, and supply either a function
to convert the object to UNQ list/tree format, a function to convert it to
text, or both.  The main functionality you get out of all this is the ability
to have Phantasmal convert from list/tree to text automatically, and a fairly
uniform, human-editable output format.

  There are similar functions to convert from UNQ tree format or text.  When
parsing, you can supply a DTD (Document Type Definition) to aid the parser in
recognizing whether the UNQ you just read fits the type you're trying to read. 
It's pretty much exactly like what XML uses for the same purpose.

  I save my object rather manually -- I call the function to convert them to
UNQ text, then write that text to a file.  Have a look at Phantasmal's InitD,
and the functions it calls on other daemons.  The MapD and ZoneD, both in
/usr/common/sys, do fairly interesting save/load routines so you can see what
using UNQ for this purpose looks like.  The MapD hands off to the simple_room
object for most object save/load stuff, so simple_room is another good one to
look at.

  You might ask, "why not use XML?"  There are two answers.  One is that XML
has those annoying extra options, the ones with equals signs and quotation
marks (see below).  The other answer is, if I wanted to use XML without that
and then give a parse error on perfectly valid XML code, I could but it would
be misleading and annoying to my readers.  I'd rather follow an uncommon
standard correctly and accurately than write a faulty implementation of a
common standard.

  Incidentally, Skotos uses variant XML for this, so my rationale doesn't
convince everybody :-)

  For reference:

<xmltag option="option-text">body</xmltag>

~unqtag{body}

  Note that UNQ uses a slightly different format -- just a closing curly brace,
not the full tag name being repeated, and no extra options after the tag name
but before the body.

--- Carter Cheng <carter_cheng at yahoo.com> wrote:

> Is there a guide on the UNQ system somewhere? I have
> been trying to understand this. I apologize if this is
> a bit newbieish again but where is the entry point
> into this subsystem? i.e. if I wanted to create my own
> zone files how does the UNQ parser know where to find
> the zone file and correctly initialize objects from
> it?
> 
>  
> ___________________________________________
> https://mail.dworkin.nl/mailman/listinfo/dgd
> 





       
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/  



More information about the DGD mailing list