/*
** SellaNMS
** $Id: configuration_parser.h,v 1.1 2005/11/26 06:48:45 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

#ifndef __DGS_LIBS_CONFIGURATION_CONFIGURATION_PARSER_H
#define __DGS_LIBS_CONFIGURATION_CONFIGURATION_PARSER_H

#ifdef HAVE_CONFIG_H
	#include "config.h"
#endif

#define INCLUDE_MAXDEPTH 32
#define NODE_ARRAY_SIZE 16

#define TOKEN_EOF					0x00
#define TOKEN_WORD				0x01
#define TOKEN_SEMICOLON			0x02
#define TOKEN_OPEN_BRACE		0x03
#define TOKEN_CLOSE_BRACE		0x04
#define TOKEN_OPEN_BRACKET		0x05
#define TOKEN_CLOSE_BRACKET	0x06

#include "configuration.h"
#include <stl/slist>
#include <stl/stack>
#include <stl/string>

typedef struct config_token {
	string			file;
	unsigned long	line;
	unsigned long	type;
};


class ConfigurationParser {
	public:
		ConfigurationParser(void);

		RESULT loadConfiguration(slist<string> &errors, ConfigNode &configuration, string configuration_file);

	protected:
		RESULT mergeNodes(ConfigNode &x, ConfigNode &y);

		RESULT convertToConfigNode(slist<string> &errors, ConfigNode &config, stack<config_token> &tokens, stack<string> &words);

		RESULT tokenizeConfiguration(slist<string> &errors, stack<config_token>  &tokens, stack<string> &words, string configuration_file, long depth = 0);
		RESULT handleToken(stack<config_token> &tokens, stack<string> &words, config_token &token, string &word, char token_char);
};

#endif

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim600: fdm=marker
** vim: noet ts=3 sw=3
*/
