phantasmal_dgd_v1/
phantasmal_dgd_v1/bin/
phantasmal_dgd_v1/doc/
phantasmal_dgd_v1/mud/doc/
phantasmal_dgd_v1/mud/doc/api/
phantasmal_dgd_v1/mud/doc/kernel/
phantasmal_dgd_v1/mud/doc/kernel/hook/
phantasmal_dgd_v1/mud/doc/kernel/lfun/
phantasmal_dgd_v1/mud/include/
phantasmal_dgd_v1/mud/include/kernel/
phantasmal_dgd_v1/mud/kernel/lib/
phantasmal_dgd_v1/mud/kernel/lib/api/
phantasmal_dgd_v1/mud/kernel/obj/
phantasmal_dgd_v1/mud/kernel/sys/
phantasmal_dgd_v1/mud/tmp/
phantasmal_dgd_v1/mud/usr/System/
phantasmal_dgd_v1/mud/usr/System/keys/
phantasmal_dgd_v1/mud/usr/System/obj/
phantasmal_dgd_v1/mud/usr/System/open/lib/
phantasmal_dgd_v1/mud/usr/common/data/
phantasmal_dgd_v1/mud/usr/common/lib/parsed/
phantasmal_dgd_v1/mud/usr/common/obj/telopt/
phantasmal_dgd_v1/mud/usr/common/obj/ustate/
phantasmal_dgd_v1/mud/usr/game/
phantasmal_dgd_v1/mud/usr/game/include/
phantasmal_dgd_v1/mud/usr/game/obj/
phantasmal_dgd_v1/mud/usr/game/object/
phantasmal_dgd_v1/mud/usr/game/object/stuff/
phantasmal_dgd_v1/mud/usr/game/sys/
phantasmal_dgd_v1/mud/usr/game/text/
phantasmal_dgd_v1/mud/usr/game/users/
phantasmal_dgd_v1/src/host/
phantasmal_dgd_v1/src/host/beos/
phantasmal_dgd_v1/src/host/mac/
phantasmal_dgd_v1/src/host/unix/
phantasmal_dgd_v1/src/host/win32/res/
phantasmal_dgd_v1/src/kfun/
phantasmal_dgd_v1/src/lpc/
phantasmal_dgd_v1/src/parser/
#include <phantasmal/phrase.h>
#include <phantasmal/lpc_names.h>

#include <type.h>

/* Phrase functions */
string as_xml(void) {
  error("Subclass must override this function!");
}

void from_xml(string xml_markup) {
  error("Subclass must override this function!");
}

string as_unq(void) {
  error("Subclass must override this function!");
}

void from_unq(string unq_markup) {
  error("Subclass must override this function!");
}


/* Utility functions */

static string taglist_to_markup(mixed *taglist, int markup_type) {
  int    ctr;
  string label, tmp, body, result;

  result = "";
  for(ctr = 0; ctr < sizeof(taglist); ctr+=2) {
    label = nil;
    if(taglist[ctr] && taglist[ctr] != "") {
      label = taglist[ctr];
    }

    switch(typeof(taglist[ctr + 1])) {
    case T_STRING:
      body = taglist[ctr + 1];
      break;
    case T_ARRAY:
      body = taglist_to_markup(taglist[ctr + 1], markup_type);
      break;
    default:
      error("Malformed taglist in taglist_to_unq!");
    }

    if(body == "") {
      /* Empty tag */
      switch(markup_type) {
      case MARKUP_UNQ:
	result += "~" + label + "{}";
	break;
      case MARKUP_XML:
	result += "<" + label + " />";
	break;
      }
    } else if(label) {
      /* Non-empty tag */
      switch(markup_type) {
      case MARKUP_UNQ:
	result += "~" + label + "{" + body + "}";
	break;
      case MARKUP_XML:
	result += "<" + label + ">" + body + "</label>";
	break;
      }
    } else {
      result += body;
    }
  }

  return result;
}

static string taglist_to_unq(mixed *taglist) {
  return taglist_to_markup(taglist, MARKUP_UNQ);
}

static string taglist_to_xml(mixed *taglist) {
  return taglist_to_markup(taglist, MARKUP_XML);
}