/***************************************************************************
*   Title : token.h
*   Desc  : 
*   Author: Jinhwan Jeon
*   Date  : 1996.5, 1996.
***************************************************************************/

#ifndef __token_h__
#define __token_h__

#include <stdio.h>

#ifndef _basicMan_h
enum operator_kind {
    OP_invalid,
    OP_and, OP_or, OP_nand, OP_nor, OP_xnor, OP_xor,// logical_operator
    OP_eq, OP_ne, OP_lt, OP_le, OP_gt, OP_ge,   // relational_operator
    OP_sll, OP_srl, OP_sla, OP_sra, OP_rol, OP_ror, // shift_operator
    OP_add, OP_sub, OP_concat,      // adding_operator
    OP_plus, OP_minus,          // sign_operator
    OP_mul, OP_div, OP_mod, OP_rem,     // multiplying_operator
    OP_exp, OP_abs, OP_not,             // miscellaneous_operator
    OP_aggregate, OP_func_call, OP_qualified,// pseudo_operator
    OP_type_conv, OP_allocator, OP_physical,
    OP_arrow, OP_choice,            // association_operator
    OP_range, OP_to, OP_downto,     // constraint_operator
    OP_selected, OP_indexed, OP_slice, OP_attribute // name_operator

};

enum attr_kind {
    A_invalid, A_user,
    // type prefix
    A_base, A_left, A_right, A_high, A_low, A_ascending, A_image,
    A_value, A_pos, A_val, A_succ, A_pred, A_leftof, A_rightof,
    // array prefix
    A_left_, A_right_, A_high_, A_low_, A_ascending_,
    A_range, A_reverse_range, A_length,
    // signal prefix
    A_delayed, A_stable, A_quiet, A_transaction,
    A_event, A_active, A_last_event, A_last_active,
    A_last_value, A_driving, A_driving_value,
    // named_entity prefix
    A_simple_name, A_instance_name, A_path_name
};
#endif //_basicMan_h

enum my_operator_kind {
	_OP_sig_assign=OP_attribute+1, 
	_OP_var_assign, 
	_OP_until, 
	_OP_for, 
	_OP_on,
	_OP_proc_call, 
	_OP_in,
	_OP_log_and,
	_OP_log_or,
	_OP_log_not,
	// for partitioning
	_OP_shift_left,
	_OP_shift_right,
	_OP_branch,
	_OP_register,
	_OP_mux,
	_OP_inp,
	_OP_outp,
	_OP_max
};

struct NameId {
	char *name;
	int  id;
};

// generic function
int name2value(NameId *tbl, const char *name);
char* value2name(NameId *tbl, int value);

// operation to literal name
char *op2name(int op);
int name2op(const char *name);

// operation to symbolic name
char *op_to_name(int op);
int name_to_op(const char *n);

// LT_TYPE to name
char *lt2name(int lt);
int name2lt(const char *name);

// HW_SW_TYPE to name
char *hs2name(int hs);
int name2hs(const char *name);

// attr_kind to name
char *attr2name(int attr);
int name2attr(const char *name);

#ifdef CDFG_GEN
char *ctrl2name(int ctrl);
int name2ctrl(const char *name);

char *node2name(int node);
int name2node(const char *name);

char *edge2name(int edge);
int name2edge(const char *name);
#endif //CDFG_GEN

#ifdef SYS_PART
char *op_to_iname(int op);
int iname_to_op(const char *n);
#endif //SYS_PART


// small lexical analyzer
int  	lexan_getno();
void 	lexan_setno(int n);
void	lexan_setcomment(char *s);
char* 	lexan_tok(FILE *fp, char *splitter, char *keyword, char *comment=0);
char* 	lexan_tok(char* sp, char *splitter, char *keyword, char *comment=0);

#endif //__token_h__
