--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+print <<EOF;
+<?xml version="1.0"?>
+<classes>
+EOF
+
+my $closetag;
+my @spawnflags;
+while(<STDIN>)
+{
+ chomp;
+ s/&/&/g;
+ s/</</g;
+ s/>/>/g;
+ s/"/"/g;
+ if(/^\/\*QUAKED (\S+) \((\S+ \S+ \S+)\) \((\S+ \S+ \S+)\) \((\S+ \S+ \S+)\) ?(.*)/)
+ {
+ print "<point name=\"$1\" color=\"$2\" box=\"$3 $4\">\n";
+ $closetag = "</point>";
+ @spawnflags = split / /, $5;
+ }
+ elsif(/^\/\*QUAKED (\S+) \((\S+ \S+ \S+)\) \? ?(.*)/)
+ {
+ print "<group name=\"$1\" color=\"$2\">\n";
+ $closetag = "</group>";
+ @spawnflags = split / /, $3;
+ }
+ elsif(/^\*\/$/)
+ {
+ print "$closetag\n";
+ }
+ elsif(/^([0-9a-z_]*): +(.*)/)
+ {
+ print "<string key=\"$1\" name=\"$1\">$2</string>\n";
+ }
+ elsif(/^([0-9A-Z_]*): +(.*)/)
+ {
+ my $bit = [grep { $spawnflags[$_] eq $1; } 0..@spawnflags-1]->[0];
+ warn "Cannot find bit $1 in @spawnflags\n"
+ if not defined $bit;
+ print "<flag key=\"$1\" name=\"$1\" bit=\"$bit\">$2</flag>\n";
+ }
+ else
+ {
+ print "$_\n";
+ }
+}
+
+print <<EOF;
+</classes>
+EOF