/***************************************************************************

    supportware
    Copyright (C) 2001-2008 by c.holzheuer
    c.holzheuer@sourceworx.org

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


#ifndef ddtoken_H
#define ddtoken_H

#include <ddbaseobject.h>

using namespace std;


/// ddtoken defines all tokens used by the ddscript compiler.
/**
	These definitions are used by the scanner and parser as tokens
	and by the vm as opcodes.

	Status: <b>beta</b><br>
	<br>
	<b>FIX:</b><br>
	<ol>
		<li>Create better documentation
		<li>Fix all remaining bugs <b>;-)</b>
		<li>...
 	</ol>
 */


class ddtoken
{

public:

	enum dd_token
	{
		t_nop		= 0,

		// basic data types
		t_invalid,		//1	//?? cleanup here!

		t_void,
		t_ddstring,
		t_int,
		t_double,

		t_object,
		t_date,
		t_currency,
		t_seq,

		t_bool,

		t_page,
		t_module,
		t_site,	//??
		t_table,
		t_section,
		t_form,
		t_tagblock,

		// token types
		t_id,
		t_value,
		t_ref,
		t_type,
		t_function,
		t_function_end,
		t_block,
		t_block_end,
		t_loop,
		t_loop_end,
		t_module_end,
		t_operator,
		t_keyword,

		// keywords
		t_do,
		t_while,
		t_for,
		t_if,
		t_else,
		t_switch,
		t_default,
		t_break,
		t_continue,
		t_return,

		t_try,
		t_throw,
		t_catch,
		t_assert,

		//system commanfs executed by the vm
		t_system,
		//print,
		//println,
		//now,
		//millis,
		//timer_start,
		//timer_elapsed,
		//set_alarm,

		// primitiv operators
		t_comma,
		t_dot,
		t_colon,
		t_semicolon,
		t_questionmark,

		t_open_brace1, // (
		t_close_brace1,// )
		t_open_brace2, // [
		t_close_brace2,// ]
		t_open_brace3, // {
		t_close_brace3, //}

		// operators
		t_assign,

		t_add,
		t_sub,
		t_mul,
		t_div,
		t_mod,
		t_int_div,
		t_concat,

		t_add_assign,
		t_sub_assign,
		t_mul_assign,
		t_div_assign,
		t_mod_assign,
		t_int_div_assign,
		t_concat_assign,

		t_greater,
		t_greater_eq,
		t_equal,
		t_not_equal,
		t_less,
		t_less_eq,

		t_log_and,
		t_log_or,

		t_not,
		t_inc,
		t_dec,
		t_preop,
		t_unary_minus,

		// vm instructions that are no keywords but in source code
		//sys_millis,

		// pure vm instructions
		t_save_sp,
		t_restore_sp,
		t_push,
		t_cast_rel,
		t_call,
		t_apply,
		t_jmp,
		t_jmpf,
		t_jmpe,
		t_jmpef,

		dd_token_size
	};

	static const char* id[];
};


#endif
