qse/ase/awk/tree.h

175 lines
3.0 KiB
C
Raw Normal View History

2006-01-09 12:51:47 +00:00
/*
2006-03-03 11:51:48 +00:00
* $Id: tree.h,v 1.24 2006-03-03 11:51:48 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_
2006-03-03 11:45:45 +00:00
#ifndef _XP_AWK_AWK_H_
2006-03-03 11:51:48 +00:00
#error Never include this file directly. Include <xp/awk/awk.h> instead
2006-03-03 11:45:45 +00:00
#endif
2006-01-09 12:51:47 +00:00
enum
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_NULL,
XP_AWK_NDE_BLOCK,
XP_AWK_NDE_BREAK,
XP_AWK_NDE_CONTINUE,
XP_AWK_NDE_RETURN,
XP_AWK_NDE_EXIT,
XP_AWK_NDE_NEXT,
XP_AWK_NDE_NEXTFILE,
XP_AWK_NDE_ASS,
XP_AWK_NDE_BINARY,
XP_AWK_NDE_UNARY,
XP_AWK_NDE_STR,
XP_AWK_NDE_NUM,
XP_AWK_NDE_NAMED,
XP_AWK_NDE_NAMEDIDX,
XP_AWK_NDE_GLOBAL,
XP_AWK_NDE_GLOBALIDX,
XP_AWK_NDE_LOCAL,
XP_AWK_NDE_LOCALIDX,
XP_AWK_NDE_ARG,
XP_AWK_NDE_ARGIDX,
XP_AWK_NDE_POS,
XP_AWK_NDE_CALL,
XP_AWK_NDE_IF,
XP_AWK_NDE_WHILE,
XP_AWK_NDE_DOWHILE,
XP_AWK_NDE_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-03-03 11:45:45 +00:00
typedef struct xp_awk_nde_t xp_awk_nde_t;
typedef struct xp_awk_nde_sgv_t xp_awk_nde_sgv_t;
typedef struct xp_awk_nde_block_t xp_awk_nde_block_t;
typedef struct xp_awk_nde_ass_t xp_awk_nde_ass_t;
typedef struct xp_awk_nde_expr_t xp_awk_nde_expr_t;
typedef struct xp_awk_nde_term_t xp_awk_nde_term_t;
typedef struct xp_awk_nde_var_t xp_awk_nde_var_t;
typedef struct xp_awk_nde_idx_t xp_awk_nde_idx_t;
typedef struct xp_awk_nde_pos_t xp_awk_nde_pos_t;
typedef struct xp_awk_nde_call_t xp_awk_nde_call_t;
typedef struct xp_awk_nde_if_t xp_awk_nde_if_t;
typedef struct xp_awk_nde_while_t xp_awk_nde_while_t;
typedef struct xp_awk_nde_for_t xp_awk_nde_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;
2006-03-03 11:45:45 +00:00
xp_awk_nde_t* body;
2006-01-22 15:11:17 +00:00
};
2006-03-03 11:45:45 +00:00
#define XP_AWK_NDE_HDR \
2006-01-09 12:51:47 +00:00
int type; \
2006-03-03 11:45:45 +00:00
xp_awk_nde_t* next
2006-01-09 12:51:47 +00:00
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_t
2006-01-09 12:51:47 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR;
2006-01-09 12:51:47 +00:00
};
2006-03-03 11:45:45 +00:00
/* XP_AWK_NDE_RETURN, XP_AWK_NDE_EXIT, XP_AWK_NDE_POS */
struct xp_awk_nde_sgv_t
2006-01-25 16:11:43 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR;
xp_awk_nde_t* value;
2006-01-25 16:11:43 +00:00
};
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_block_t
2006-01-09 12:51:47 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR;
2006-02-04 19:31:51 +00:00
xp_size_t nlocals;
2006-03-03 11:45:45 +00:00
xp_awk_nde_t* body;
2006-01-09 12:51:47 +00:00
};
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_ass_t
2006-01-11 14:03:17 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR;
xp_awk_nde_t* left;
xp_awk_nde_t* right;
2006-01-11 14:03:17 +00:00
};
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_expr_t
2006-01-10 13:57:54 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR;
2006-01-11 14:03:17 +00:00
int opcode;
2006-03-03 11:45:45 +00:00
xp_awk_nde_t* left;
xp_awk_nde_t* right;
2006-01-10 13:57:54 +00:00
};
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_term_t
2006-01-10 13:57:54 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR;
2006-01-12 14:20:17 +00:00
xp_char_t* value;
2006-01-10 13:57:54 +00:00
};
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_var_t
2006-01-24 16:14:28 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR;
struct // union
2006-01-24 16:14:28 +00:00
{
xp_char_t* name;
xp_size_t idxa;
} id;
};
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_idx_t
2006-01-13 11:25:52 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR;
2006-02-01 02:56:12 +00:00
struct // union
2006-01-24 16:14:28 +00:00
{
xp_char_t* name;
xp_size_t idxa;
} id;
2006-03-03 11:45:45 +00:00
xp_awk_nde_t* idx;
2006-01-19 16:28:21 +00:00
};
2006-01-25 14:50:57 +00:00
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_call_t
2006-01-19 16:28:21 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR; /* XP_AWK_NDE_CALL */
2006-01-19 16:28:21 +00:00
xp_char_t* name;
2006-03-03 11:45:45 +00:00
xp_awk_nde_t* args;
2006-01-13 11:25:52 +00:00
};
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_if_t
2006-01-09 12:51:47 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR; /* XP_AWK_NDE_IF */
xp_awk_nde_t* test;
xp_awk_nde_t* then_part;
xp_awk_nde_t* else_part; /* optional */
2006-01-09 12:51:47 +00:00
};
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_while_t
2006-01-10 13:57:54 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR; /* XP_AWK_NDE_WHILE, XP_AWK_NDE_DOWHILE */
xp_awk_nde_t* test;
xp_awk_nde_t* body;
2006-01-10 13:57:54 +00:00
};
2006-03-03 11:45:45 +00:00
struct xp_awk_nde_for_t
2006-01-19 13:28:29 +00:00
{
2006-03-03 11:45:45 +00:00
XP_AWK_NDE_HDR; /* XP_AWK_NDE_FOR */
xp_awk_nde_t* init; /* optional */
xp_awk_nde_t* test; /* optional */
xp_awk_nde_t* incr; /* optional */
xp_awk_nde_t* body;
2006-01-19 13:28:29 +00:00
};
2006-01-14 14:09:52 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2006-03-03 11:45:45 +00:00
void xp_awk_prnpt (xp_awk_nde_t* tree);
void xp_awk_clrpt (xp_awk_nde_t* tree);
2006-01-14 14:09:52 +00:00
#ifdef __cplusplus
}
#endif
2006-01-09 12:51:47 +00:00
#endif