#include "main.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <ext/hash_map>
#include <vector>
#include <string>

int main(int argc, char **argv) {
	clear(root);

	add("discovery:::icmp:::source");
	add("discovery:::icmp:::interface");
	add("discovery:::icmp:::transmit");
	add("discovery:::icmp:::require");
	add("discovery:::icmp:::timeout");
	add("discovery:::icmp:::prefix");
	add("discovery:::icmp:::trace-options");

	add("discovery:::snmp:::source");
	add("discovery:::snmp:::interface");
	add("discovery:::snmp:::commit-count");
	add("discovery:::snmp:::threads");
	add("discovery:::snmp:::community");
	add("discovery:::snmp:::timeout");
	add("discovery:::snmp:::retry");
	add("discovery:::snmp:::prefix");
	add("discovery:::snmp:::oid");
	add("discovery:::snmp:::trace-options");

	add("discovery:::topology:::policy:::input");
	add("discovery:::topology:::merge-percent");
	add("discovery:::topology:::duplicate-percent");
	add("discovery:::topology:::maximum-element-delete");
	add("discovery:::topology:::trace-options");

	add("monitor:::icmp:::interval");
	add("monitor:::icmp:::source");
	add("monitor:::icmp:::interface");
	add("monitor:::icmp:::payload");
	add("monitor:::icmp:::timeout");
	add("monitor:::icmp:::transmit");
	add("monitor:::icmp:::ttl");
	add("monitor:::icmp:::tos");
	add("monitor:::icmp:::dscp");
	add("monitor:::icmp:::precedence");
	add("monitor:::icmp:::max-rtt");
	add("monitor:::icmp:::trace-options");
	add("monitor:::icmp:::policy:::input");
	add("monitor:::icmp:::policy:::output");
	add("monitor:::icmp:::calc-queue-depth");
	add("monitor:::icmp:::queue-depth");
	add("monitor:::icmp:::policy-queue-depth");
	add("monitor:::icmp:::policy-queue-limit-max");
	add("monitor:::icmp:::calc-interval");
	add("monitor:::icmp:::calc-interval-adjustment");
	add("monitor:::icmp:::supression:::packet-loss");
	add("monitor:::icmp:::supression:::latency");
	add("monitor:::icmp:::supression:::jitter");
	add("monitor:::icmp:::supression:::normalized-latency");

	add("monitor:::snmptrap:::queue-depth");
	add("monitor:::snmptrap:::trace-options");
	add("monitor:::snmptrap:::policy:::input");
	add("monitor:::snmptrap:::policy:::output");
	add("monitor:::snmptrap:::source");
	add("monitor:::snmptrap:::interface");
	add("monitor:::snmptrap:::proxy:::convert");
	add("monitor:::snmptrap:::port");
	add("monitor:::snmptrap:::exit-after");

	add("monitor:::syslog:::source");
	add("monitor:::syslog:::interface");
	add("monitor:::syslog:::duplicate-history-max");
	add("monitor:::syslog:::duplicate-history-age");
	add("monitor:::syslog:::duplicate-fuzz-factor");
	add("monitor:::syslog:::exit-after");
	add("monitor:::syslog:::queue-depth");
	add("monitor:::syslog:::trace-options");
	add("monitor:::syslog:::policy:::input");
	add("monitor:::syslog:::policy:::output");

	add("monitor:::state:::interval");
	add("monitor:::state:::trace-options");
	add("monitor:::state:::policy:::output");

	add("output:::gui:::interval");
	add("output:::gui:::max-storage-delete");
	add("output:::gui:::trace-options");
	add("output:::gui:::policy:::output");

	add("output:::email:::queue-depth");
	add("output:::email:::policy:::output");
	add("output:::email:::trace-options");

	add("system:::storage:::primary:::driver");
	add("system:::storage:::primary:::server");
	add("system:::storage:::primary:::port");
	add("system:::storage:::primary:::database");
	add("system:::storage:::primary:::username");
	add("system:::storage:::primary:::password");
	add("system:::snmp-mib");
	add("system:::library");
	add("system:::module:::default:::nice");
	add("system:::module:::default:::restart");
	add("system:::module:::default:::user");
	add("system:::module:::default:::config");
	add("system:::module:::default:::directory");
	add("system:::module:::default:::facility");
	add("system:::module:::discovery:::nice");
	add("system:::module:::discovery:::no-restart");
	add("system:::module:::discovery:::schedule:::startup");
	add("system:::module:::discovery:::schedule:::hour");
	add("system:::module:::discovery:::schedule:::minute");
	add("system:::module:::discovery:::schedule:::second");
	add("system:::module:::discovery:::icmp:::executable");
	add("system:::module:::discovery:::icmp:::description");
	add("system:::module:::discovery:::icmp:::order");
	add("system:::module:::discovery:::snmp:::executable");
	add("system:::module:::discovery:::snmp:::description");
	add("system:::module:::discovery:::snmp:::order");
	add("system:::module:::discovery:::topology:::executable");
	add("system:::module:::discovery:::topology:::description");
	add("system:::module:::discovery:::topology:::order");
	add("system:::module:::monitor:::icmp:::executable");
	add("system:::module:::monitor:::icmp:::description");
	add("system:::module:::monitor:::snmptrap:::executable");
	add("system:::module:::monitor:::snmptrap:::description");
	add("system:::module:::monitor:::syslog:::executable");
	add("system:::module:::monitor:::syslog:::description");
	add("system:::module:::monitor:::state:::executable");
	add("system:::module:::monitor:::state:::description");
	add("system:::module:::output:::gui:::executable");
	add("system:::module:::output:::gui:::description");
	add("system:::module:::output:::email:::executable");
	add("system:::module:::output:::email:::description");

	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::apply-format");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::set");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::apply-map");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::gui:::brief");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::gui:::detail");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::gui:::channel");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::log:::brief");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::log:::detail");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::log:::channel");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::email:::brief");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::email:::detail");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::email:::channel");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::state:::protocol");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::state:::channel");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::output:::state:::state");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::evaluate:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::accept");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::reject");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::next-term");
	add("policy-options:::policy-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::next-policy");

	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::required");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::type");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::function");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::apply-map");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::value");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::suffix-modifier[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::function");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::suffix-modifier[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::argument");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::dependency[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*");

	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::required");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::type");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::function");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::apply-map");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::value");

	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::required");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::type");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::function");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::apply-map");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::value");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::suffix-modifier[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::function");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::suffix-modifier[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::argument");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::suffix-modifier[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::function");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::suffix-modifier[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::argument");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::dependency[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::group[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::dependency[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*");

	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::action:::default");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::action:::value");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::set:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::value");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::set:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::type");
	add("policy-options:::format-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::set:::variable[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::required");

	add("policy-options:::map-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::from:::query");
	add("policy-options:::map-statement[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::term[ 	][ 	]*[A-Za-z0-9_\\-:][A-Za-z0-9_\\-:]*[ 	]*:::then:::set");

	printHead();
	print(&root, "", false);
	printFoot();

	return 0;
}

int clear(node &n) {
	n.value.clear();
	memset(n.children, 0, sizeof(node *) * 255);
}

vector<string>	*split(string input, string separator) {
	vector<string>		*result = new vector<string>;

	string::size_type	begin = 0;
	string::size_type	end = 0;

	string				value;

	while ((end = input.find(separator, begin)) < input.size()) {
		value = input.substr(begin, end - begin);
		result->push_back(value);

		begin = end + separator.size();
	}
	if (begin < end) {
		value = input.substr(begin, end - begin);
		result->push_back(value);

		begin = end + separator.size();
	}

	return result;
}

int add(string	value) {
	vector<string>		*parts = split(value, SEPARATOR);
	string::size_type	illegal = 0;
	string::size_type	end = 0;

	node	*n = &root;
	int	c = 0;
	for (vector<string>::iterator	i = parts->begin(); i != parts->end(); ++i) {
		c = 0;
		while (n->children[c] != NULL) {
			if (i->compare(n->children[c]->value) != 0) {
				c++;
			} else {
				break;
			}
		}
		if (n->children[c] == NULL) {
			n->children[c] = new node;
			clear(*(n->children[c]));
		}
		n = n->children[c];
		n->value = *i;	


		while ((illegal = i->find(".")) < i->size()) {
			i->erase(illegal, 1);
		}
		while ((illegal = i->find("*")) < i->size()) {
			i->erase(illegal, 1);
		}
		while ((illegal = i->find("\\")) < i->size()) {
			i->erase(illegal, 1);
		}
		while ((illegal = i->find("$")) < i->size()) {
			i->erase(illegal, 1);
		}
		while ((illegal = i->find(":")) < i->size()) {
			i->erase(illegal, 1);
		}
		while ((illegal = i->find("^")) < i->size()) {
			i->erase(illegal, 1);
		}
		while ((illegal = i->find(" ")) < i->size()) {
			i->erase(illegal, 1);
		}
		while ((illegal = i->find("	")) < i->size()) {
			i->erase(illegal, 1);
		}
		while ((illegal = i->find("[")) < i->size()) {
			if ((end = i->find("]")) < i->size()) {
				i->erase(illegal, end - illegal + 1);
			}
		}
		n->c_value = *i;

		while ((illegal = i->find("-")) < i->size()) {
			i->erase(illegal, 1);
		}

		n->v_value = *i;
	}
	delete parts;
}

int print(node *n = &root, string prefix = "", bool contained = false) {
	string	subprefix;
	int		c = 0;

	if (n == &root) {
		for (int i = 0; (n->children[i]) != NULL; i++) {
			print(n->children[i], n->v_value, false);
		}
		return 0;
	}
	fprintf(stdout, "syntax match s_%s%s \"%s[ 	]*{.*$\" transparent %scontains=s_%s%s_keyword,s_%s%s_clause\n", prefix.c_str(), n->v_value.c_str(), n->value.c_str(), (contained == false) ? "" : "contained ", prefix.c_str(), n->v_value.c_str(), prefix.c_str(), n->v_value.c_str());
//	if (n->children[0] == NULL) {
		fprintf(stdout, "syntax match ss_%s%s \"%s[ 	]*[^{]*$\" transparent %scontains=s_%s%s_keyword\n", prefix.c_str(), n->v_value.c_str(), n->value.c_str(), (contained == false) ? "" : "contained ", prefix.c_str(), n->v_value.c_str());
//	}

	/* Print Clause Section */
	if (n->children[0] != NULL) {
		fprintf(stdout, "syntax region s_%s%s_clause start=\"{\" end=\"}\" transparent contained extend contains=", prefix.c_str(), n->v_value.c_str());
	} else {
		fprintf(stdout, "syntax region s_%s%s_clause start=\"{\" end=\"}\" transparent contained extend", prefix.c_str(), n->v_value.c_str());
	}
	c = 0;
	for (int i = 0; (n->children[i]) != NULL; i++) {
		if (c > 0) {
			fprintf(stdout, ",");
		}
		fprintf(stdout, "s_%s%s_%s", prefix.c_str(), n->v_value.c_str(), n->children[i]->v_value.c_str());
//		if (n->children[i]->children[0] == NULL) {
			fprintf(stdout, ",ss_%s%s_%s", prefix.c_str(), n->v_value.c_str(), n->children[i]->v_value.c_str());
//		}

		c++;
	}
	fprintf(stdout, "\n");

	/* Print Keyword Section */
	if (n->c_value.size() > 0) {
		fprintf(stdout, "syntax keyword s_%s%s_keyword contained %s\n\n", prefix.c_str(), n->v_value.c_str(), n->c_value.c_str());
	} else {
		fprintf(stdout, "syntax keyword s_%s%s_keyword contained %s\n\n", prefix.c_str(), n->v_value.c_str(), n->value.c_str());
	}

	subprefix = prefix + n->v_value + "_";
	for (int i = 0; (n->children[i]) != NULL; i++) {
		print(n->children[i], subprefix, true);
	}
	return 0;
}

int printLink(node *n = &root, string prefix = "") {
	string	subprefix;

	if (n == &root) {
		for (int i = 0; (n->children[i]) != NULL; i++) {
			printLink(n->children[i], n->value);
		}
		return 0;
	}
	if ((n->children[0]) != NULL) {
		fprintf(stdout, "   HiLink s_%s%s_keyword Keyword\n", prefix.c_str(), n->v_value.c_str());
	} else {
		fprintf(stdout, "   HiLink s_%s%s_keyword Type\n", prefix.c_str(), n->v_value.c_str());
	}

	subprefix = prefix + n->v_value + "_";
	for (int i = 0; (n->children[i]) != NULL; i++) {
		printLink(n->children[i], subprefix);
	}
	return 0;
}

int printHead() {
	fprintf(stdout, "\" Vim syntax file\n");
	fprintf(stdout, "\" $Id: main.cxx,v 1.5 2005/05/30 01:21:17 bill Exp $\n");
	fprintf(stdout, "\" Language: SellaNMS Configuration\n");
	fprintf(stdout, "\" Maintainer:  mkvim (auto-generated)\n");
	fprintf(stdout, "\" Last Change: 2005 April 30\n");
	fprintf(stdout, "\n");
	fprintf(stdout, "\" For version 5.x: Clear all syntax items\n");
	fprintf(stdout, "\" For version 6.x: Quit when a syntax file was already loaded\n");
	fprintf(stdout, "\n");
	fprintf(stdout, "if version < 600\n");
	fprintf(stdout, "   syntax clear\n");
	fprintf(stdout, "elseif exists(\"b:current_syntax\")\n");
	fprintf(stdout, "   finish\n");
	fprintf(stdout, "endif\n");
	fprintf(stdout, "\n");
	fprintf(stdout, "syntax case match\n");
	fprintf(stdout, "syntax sync fromstart\n");
	fprintf(stdout, "\n");
	fprintf(stdout, "setlocal iskeyword+=-\n");
	fprintf(stdout, "\n");
	fprintf(stdout, "syntax region s_comment_cpp start=\"//\" end=\"$\" containedin=ALL keepend extend\n");
	fprintf(stdout, "syntax region s_comment_sql start=\"--\" end=\"$\" containedin=ALL keepend extend\n");
	fprintf(stdout, "syntax region s_comment_shell start=\"#\"  end=\"$\" containedin=ALL keepend extend contains=s_include\n");
	fprintf(stdout, "syntax region s_comment_c start=\"/\\*\" end=\"\\*/\" containedin=ALL keepend extend\n");
	fprintf(stdout, "\n");
	fprintf(stdout, "syntax region s_included start=\"\\\"\" end=\"\\\"\" display contained\n");
	fprintf(stdout, "syntax match s_include \"^\\s*#\\s*include\\>\\s*[\"<]\" display contained contains=s_included\n");
	fprintf(stdout, "\n");
	fprintf(stdout, "syntax region s_string start=+\"+ end=+\"+ containedin=ALL keepend\n");
	fprintf(stdout, "syntax region s_variable start=+@+ end=+@+ containedin=ALL oneline keepend\n");
	fprintf(stdout, "syntax match s_snmpcolon \"snmp:\" containedin=ALL\n");
	fprintf(stdout, "syntax match s_disable \"disable\" containedin=ALL\n");
	fprintf(stdout, "\n");
}

int printFoot() {
	fprintf(stdout, "if version >= 508 || !exists(\"did_c_syn_inits\")\n");
	fprintf(stdout, "   if version < 508\n");
	fprintf(stdout, "      let did_c_syn_inits = 1\n");
	fprintf(stdout, "      command -nargs=+ HiLink hi link <args>\n");
	fprintf(stdout, "   else\n");
	fprintf(stdout, "      command -nargs=+ HiLink hi def link <args>\n");
	fprintf(stdout, "   endif\n");
	fprintf(stdout, "   \n");
	fprintf(stdout, "   HiLink s_comment_cpp Comment\n");
	fprintf(stdout, "   HiLink s_comment_sql Comment\n");
	fprintf(stdout, "   HiLink s_comment_shell Comment\n");
	fprintf(stdout, "   HiLink s_comment_c Comment\n");
	fprintf(stdout, "   HiLink s_include Include\n");
	fprintf(stdout, "   HiLink s_string String\n");
	fprintf(stdout, "   HiLink s_variable Operator\n");
	fprintf(stdout, "   HiLink s_snmpcolon Identifier\n");
	fprintf(stdout, "   HiLink s_disable Error\n");
	fprintf(stdout, "   \n");

	printLink();	

	fprintf(stdout, "   \n");
	fprintf(stdout, "   delcommand HiLink\n");
	fprintf(stdout, "endif\n");
	fprintf(stdout, "   \n");
	fprintf(stdout, "let b:current_syntax = \"sella_nms\"\n");
}

