2006-01-09 12:51:47 +00:00
|
|
|
/*
|
2006-01-30 14:34:47 +00:00
|
|
|
* $Id: tree.h,v 1.19 2006-01-30 14:34:47 bacon Exp $
|
2006-01-09 12:51:47 +00:00
|
|
|
*/
|
2006-01-02 16:38:23 +00:00
|
|
|
|
2006-01-09 12:51:47 +00:00
|
|
|
#ifndef _XP_AWK_TREE_H_
|
|
|
|
#define _XP_AWK_TREE_H_
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2006-01-18 16:12:59 +00:00
|
|
|
XP_AWK_NODE_NULL,
|
2006-01-09 12:51:47 +00:00
|
|
|
XP_AWK_NODE_BLOCK,
|
|
|
|
XP_AWK_NODE_BREAK,
|
2006-01-11 14:03:17 +00:00
|
|
|
XP_AWK_NODE_CONTINUE,
|
2006-01-14 14:09:52 +00:00
|
|
|
XP_AWK_NODE_RETURN,
|
|
|
|
XP_AWK_NODE_EXIT,
|
2006-01-20 07:33:46 +00:00
|
|
|
XP_AWK_NODE_NEXT,
|
|
|
|
XP_AWK_NODE_NEXTFILE,
|
2006-01-11 14:03:17 +00:00
|
|
|
XP_AWK_NODE_ASSIGN,
|
|
|
|
XP_AWK_NODE_BINARY,
|
|
|
|
XP_AWK_NODE_UNARY,
|
2006-01-12 14:20:17 +00:00
|
|
|
XP_AWK_NODE_STR,
|
|
|
|
XP_AWK_NODE_NUM,
|
|
|
|
XP_AWK_NODE_VAR,
|
2006-01-24 16:14:28 +00:00
|
|
|
XP_AWK_NODE_VARIDX,
|
|
|
|
XP_AWK_NODE_ARG,
|
|
|
|
XP_AWK_NODE_ARGIDX,
|
2006-01-25 14:50:57 +00:00
|
|
|
XP_AWK_NODE_POS,
|
2006-01-14 16:09:58 +00:00
|
|
|
XP_AWK_NODE_CALL,
|
2006-01-18 16:12:59 +00:00
|
|
|
XP_AWK_NODE_IF,
|
2006-01-19 10:56:35 +00:00
|
|
|
XP_AWK_NODE_WHILE,
|
2006-01-19 13:28:29 +00:00
|
|
|
XP_AWK_NODE_DOWHILE,
|
|
|
|
XP_AWK_NODE_FOR
|
2006-01-09 12:51:47 +00:00
|
|
|
};
|
|
|
|
|
2006-01-30 14:34:47 +00:00
|
|
|
typedef struct xp_awk_func_t xp_awk_func_t;
|
|
|
|
|
2006-01-09 12:51:47 +00:00
|
|
|
typedef struct xp_awk_node_t xp_awk_node_t;
|
2006-01-25 16:11:43 +00:00
|
|
|
typedef struct xp_awk_node_sgv_t xp_awk_node_sgv_t;
|
2006-01-09 12:51:47 +00:00
|
|
|
typedef struct xp_awk_node_block_t xp_awk_node_block_t;
|
2006-01-11 14:03:17 +00:00
|
|
|
typedef struct xp_awk_node_assign_t xp_awk_node_assign_t;
|
2006-01-10 13:57:54 +00:00
|
|
|
typedef struct xp_awk_node_expr_t xp_awk_node_expr_t;
|
|
|
|
typedef struct xp_awk_node_term_t xp_awk_node_term_t;
|
2006-01-24 16:14:28 +00:00
|
|
|
typedef struct xp_awk_node_var_t xp_awk_node_var_t;
|
2006-01-19 16:28:21 +00:00
|
|
|
typedef struct xp_awk_node_idx_t xp_awk_node_idx_t;
|
2006-01-25 14:50:57 +00:00
|
|
|
typedef struct xp_awk_node_pos_t xp_awk_node_pos_t;
|
2006-01-13 14:16:56 +00:00
|
|
|
typedef struct xp_awk_node_call_t xp_awk_node_call_t;
|
2006-01-09 12:51:47 +00:00
|
|
|
typedef struct xp_awk_node_if_t xp_awk_node_if_t;
|
2006-01-10 13:57:54 +00:00
|
|
|
typedef struct xp_awk_node_while_t xp_awk_node_while_t;
|
2006-01-19 13:28:29 +00:00
|
|
|
typedef struct xp_awk_node_for_t xp_awk_node_for_t;
|
2006-01-09 12:51:47 +00:00
|
|
|
|
2006-01-22 15:11:17 +00:00
|
|
|
struct xp_awk_func_t
|
|
|
|
{
|
|
|
|
xp_char_t* name;
|
|
|
|
xp_size_t nargs;
|
|
|
|
xp_awk_node_t* body;
|
|
|
|
};
|
|
|
|
|
2006-01-09 12:51:47 +00:00
|
|
|
#define XP_AWK_NODE_HDR \
|
|
|
|
int type; \
|
2006-01-10 13:57:54 +00:00
|
|
|
xp_awk_node_t* next
|
2006-01-09 12:51:47 +00:00
|
|
|
|
|
|
|
struct xp_awk_node_t
|
|
|
|
{
|
|
|
|
XP_AWK_NODE_HDR;
|
|
|
|
};
|
|
|
|
|
2006-01-25 16:11:43 +00:00
|
|
|
/* XP_AWK_NODE_RETURN, XP_AWK_NODE_EXIT, XP_AWK_NODE_POS */
|
|
|
|
struct xp_awk_node_sgv_t
|
|
|
|
{
|
|
|
|
XP_AWK_NODE_HDR;
|
|
|
|
xp_awk_node_t* value;
|
|
|
|
};
|
|
|
|
|
2006-01-09 12:51:47 +00:00
|
|
|
struct xp_awk_node_block_t
|
|
|
|
{
|
|
|
|
XP_AWK_NODE_HDR;
|
2006-01-25 16:11:43 +00:00
|
|
|
xp_size_t lvc; /* local variable count */
|
2006-01-09 12:51:47 +00:00
|
|
|
xp_awk_node_t* body;
|
|
|
|
};
|
|
|
|
|
2006-01-11 14:03:17 +00:00
|
|
|
struct xp_awk_node_assign_t
|
|
|
|
{
|
|
|
|
XP_AWK_NODE_HDR;
|
2006-01-20 07:33:46 +00:00
|
|
|
xp_awk_node_t* left;
|
2006-01-11 14:03:17 +00:00
|
|
|
xp_awk_node_t* right;
|
|
|
|
};
|
|
|
|
|
2006-01-10 13:57:54 +00:00
|
|
|
struct xp_awk_node_expr_t
|
|
|
|
{
|
|
|
|
XP_AWK_NODE_HDR;
|
2006-01-11 14:03:17 +00:00
|
|
|
int opcode;
|
2006-01-10 13:57:54 +00:00
|
|
|
xp_awk_node_t* left;
|
|
|
|
xp_awk_node_t* right;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct xp_awk_node_term_t
|
|
|
|
{
|
|
|
|
XP_AWK_NODE_HDR;
|
2006-01-12 14:20:17 +00:00
|
|
|
xp_char_t* value;
|
2006-01-10 13:57:54 +00:00
|
|
|
};
|
|
|
|
|
2006-01-24 16:14:28 +00:00
|
|
|
struct xp_awk_node_var_t
|
|
|
|
{
|
|
|
|
XP_AWK_NODE_HDR;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
xp_char_t* name;
|
|
|
|
xp_size_t idxa;
|
|
|
|
} id;
|
|
|
|
};
|
|
|
|
|
2006-01-19 16:28:21 +00:00
|
|
|
struct xp_awk_node_idx_t
|
2006-01-13 11:25:52 +00:00
|
|
|
{
|
|
|
|
XP_AWK_NODE_HDR;
|
2006-01-24 16:14:28 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
xp_char_t* name;
|
|
|
|
xp_size_t idxa;
|
|
|
|
} id;
|
2006-01-19 16:28:21 +00:00
|
|
|
xp_awk_node_t* idx;
|
|
|
|
};
|
|
|
|
|
2006-01-25 14:50:57 +00:00
|
|
|
|
2006-01-19 16:28:21 +00:00
|
|
|
struct xp_awk_node_call_t
|
|
|
|
{
|
|
|
|
XP_AWK_NODE_HDR; /* XP_AWK_NODE_CALL */
|
|
|
|
xp_char_t* name;
|
2006-01-13 14:16:56 +00:00
|
|
|
xp_awk_node_t* args;
|
2006-01-13 11:25:52 +00:00
|
|
|
};
|
|
|
|
|
2006-01-09 12:51:47 +00:00
|
|
|
struct xp_awk_node_if_t
|
|
|
|
{
|
2006-01-19 16:28:21 +00:00
|
|
|
XP_AWK_NODE_HDR; /* XP_AWK_NODE_IF */
|
2006-01-10 13:57:54 +00:00
|
|
|
xp_awk_node_t* test;
|
|
|
|
xp_awk_node_t* then_part;
|
2006-01-19 16:28:21 +00:00
|
|
|
xp_awk_node_t* else_part; /* optional */
|
2006-01-09 12:51:47 +00:00
|
|
|
};
|
|
|
|
|
2006-01-10 13:57:54 +00:00
|
|
|
struct xp_awk_node_while_t
|
|
|
|
{
|
2006-01-19 16:28:21 +00:00
|
|
|
XP_AWK_NODE_HDR; /* XP_AWK_NODE_WHILE, XP_AWK_NODE_DOWHILE */
|
2006-01-10 13:57:54 +00:00
|
|
|
xp_awk_node_t* test;
|
|
|
|
xp_awk_node_t* body;
|
|
|
|
};
|
|
|
|
|
2006-01-19 13:28:29 +00:00
|
|
|
struct xp_awk_node_for_t
|
|
|
|
{
|
2006-01-19 16:28:21 +00:00
|
|
|
XP_AWK_NODE_HDR; /* XP_AWK_NODE_FOR */
|
|
|
|
xp_awk_node_t* init; /* optional */
|
|
|
|
xp_awk_node_t* test; /* optional */
|
|
|
|
xp_awk_node_t* incr; /* optional */
|
2006-01-19 13:28:29 +00:00
|
|
|
xp_awk_node_t* body;
|
|
|
|
};
|
|
|
|
|
2006-01-14 14:09:52 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void xp_awk_prnpt (xp_awk_node_t* tree);
|
|
|
|
void xp_awk_clrpt (xp_awk_node_t* tree);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-01-09 12:51:47 +00:00
|
|
|
#endif
|