diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 7de2981e..7940903e 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.111 2006-06-12 15:11:02 bacon Exp $ + * $Id: parse.c,v 1.112 2006-06-13 08:35:53 bacon Exp $ */ #include @@ -86,6 +86,8 @@ enum TOKEN_GETLINE, TOKEN_NEXT, TOKEN_NEXTFILE, + TOKEN_PRINT, + TOKEN_PRINTF, TOKEN_LOCAL, TOKEN_GLOBAL, @@ -151,6 +153,8 @@ static xp_awk_nde_t* __parse_return (xp_awk_t* awk); static xp_awk_nde_t* __parse_exit (xp_awk_t* awk); static xp_awk_nde_t* __parse_delete (xp_awk_t* awk); static xp_awk_nde_t* __parse_getline (xp_awk_t* awk); +static xp_awk_nde_t* __parse_print (xp_awk_t* awk); +static xp_awk_nde_t* __parse_printf (xp_awk_t* awk); static xp_awk_nde_t* __parse_next (xp_awk_t* awk); static xp_awk_nde_t* __parse_nextfile (xp_awk_t* awk); @@ -193,6 +197,8 @@ static struct __kwent __kwtab[] = { XP_T("getline"), TOKEN_GETLINE, 0 }, { XP_T("next"), TOKEN_NEXT, 0 }, { XP_T("nextfile"), TOKEN_NEXTFILE, 0 }, + { XP_T("print"), TOKEN_PRINT, 0 }, + { XP_T("printf"), TOKEN_PRINTF, 0 }, { XP_T("local"), TOKEN_LOCAL, XP_AWK_EXPLICIT }, { XP_T("global"), TOKEN_GLOBAL, XP_AWK_EXPLICIT }, @@ -1077,6 +1083,16 @@ static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk) if (__get_token(awk) == -1) return XP_NULL; nde = __parse_nextfile(awk); } + else if (MATCH(awk,TOKEN_PRINT)) + { + if (__get_token(awk) == -1) return XP_NULL; + nde = __parse_print(awk); + } + else if (MATCH(awk,TOKEN_PRINTF)) + { + if (__get_token(awk) == -1) return XP_NULL; + nde = __parse_printf(awk); + } else { nde = __parse_expression(awk); @@ -1485,7 +1501,7 @@ static xp_awk_nde_t* __parse_bitwise_or (xp_awk_t* awk) nde->next = XP_NULL; nde->var = var; nde->cmd = left; - nde->out = XP_NULL; + nde->in = XP_NULL; left = (xp_awk_nde_t*)nde; } @@ -2653,6 +2669,70 @@ static xp_awk_nde_t* __parse_getline (xp_awk_t* awk) return XP_NULL; } +static xp_awk_nde_t* __parse_print (xp_awk_t* awk) +{ + xp_awk_nde_print_t* nde; + xp_awk_nde_t* args = XP_NULL; + xp_awk_nde_t* out = XP_NULL; + int out_type = -1; + + /* TODO: expression list............ */ + if (!MATCH(awk,TOKEN_SEMICOLON) && + !MATCH(awk,TOKEN_GT) && + !MATCH(awk,TOKEN_BOR)) + { + args = __parse_expression (awk); + if (args == XP_NULL) return XP_NULL; + } + + if (MATCH(awk,TOKEN_GT)) + { + out_type = XP_AWK_PRINT_FILE; + } + else if (MATCH(awk,TOKEN_BOR)) + { + out_type = XP_AWK_PRINT_PIPE; + } + + if (out_type != -1) + { + if (__get_token(awk) == -1) + { + if (args != XP_NULL) xp_awk_clrpt (args); + return XP_NULL; + } + + out = __parse_expression(awk); + if (out == XP_NULL) + { + if (args != XP_NULL) xp_awk_clrpt (args); + return XP_NULL; + } + } + + nde = (xp_awk_nde_print_t*)xp_malloc(xp_sizeof(xp_awk_nde_print_t)); + if (nde == XP_NULL) + { + if (args != XP_NULL) xp_awk_clrpt (args); + if (out != XP_NULL) xp_awk_clrpt (out); + PANIC (awk, XP_AWK_ENOMEM); + } + + nde->type = XP_AWK_NDE_PRINT; + nde->next = XP_NULL; + nde->args = args; + nde->out_type = out_type; + nde->out = out; + + return (xp_awk_nde_t*)nde; +} + +static xp_awk_nde_t* __parse_printf (xp_awk_t* awk) +{ +/* TODO: implement this... */ + return XP_NULL; +} + static xp_awk_nde_t* __parse_next (xp_awk_t* awk) { xp_awk_nde_next_t* nde; diff --git a/ase/awk/run.c b/ase/awk/run.c index 583bb3e1..4b155ff1 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.93 2006-06-12 15:11:02 bacon Exp $ + * $Id: run.c,v 1.94 2006-06-13 08:35:53 bacon Exp $ */ #include @@ -54,6 +54,7 @@ static int __run_return_statement (xp_awk_run_t* run, xp_awk_nde_return_t* nde); static int __run_exit_statement (xp_awk_run_t* run, xp_awk_nde_exit_t* nde); static int __run_next_statement (xp_awk_run_t* run, xp_awk_nde_next_t* nde); static int __run_nextfile_statement (xp_awk_run_t* run, xp_awk_nde_nextfile_t* nde); +static int __run_print_statement (xp_awk_run_t* run, xp_awk_nde_print_t* nde); static xp_awk_val_t* __eval_expression ( xp_awk_run_t* run, xp_awk_nde_t* nde); @@ -591,74 +592,106 @@ static int __run_statement (xp_awk_run_t* run, xp_awk_nde_t* nde) { switch (nde->type) { - case XP_AWK_NDE_NULL: - /* do nothing */ - break; + case XP_AWK_NDE_NULL: + { + /* do nothing */ + break; + } - case XP_AWK_NDE_BLK: - if (__run_block(run,(xp_awk_nde_blk_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_BLK: + { + if (__run_block ( + run, (xp_awk_nde_blk_t*)nde) == -1) return -1; + break; + } - case XP_AWK_NDE_IF: - if (__run_if_statement ( - run, (xp_awk_nde_if_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_IF: + { + if (__run_if_statement ( + run, (xp_awk_nde_if_t*)nde) == -1) return -1; + break; + } - case XP_AWK_NDE_WHILE: - case XP_AWK_NDE_DOWHILE: - if (__run_while_statement ( - run, (xp_awk_nde_while_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_WHILE: + case XP_AWK_NDE_DOWHILE: + { + if (__run_while_statement ( + run, (xp_awk_nde_while_t*)nde) == -1) return -1; + break; + } - case XP_AWK_NDE_FOR: - if (__run_for_statement ( - run, (xp_awk_nde_for_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_FOR: + { + if (__run_for_statement ( + run, (xp_awk_nde_for_t*)nde) == -1) return -1; + break; + } - case XP_AWK_NDE_FOREACH: - if (__run_foreach_statement ( - run, (xp_awk_nde_foreach_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_FOREACH: + { + if (__run_foreach_statement ( + run, (xp_awk_nde_foreach_t*)nde) == -1) return -1; + break; + } - case XP_AWK_NDE_BREAK: - if (__run_break_statement( - run, (xp_awk_nde_break_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_BREAK: + { + if (__run_break_statement( + run, (xp_awk_nde_break_t*)nde) == -1) return -1; + break; + } - case XP_AWK_NDE_CONTINUE: - if (__run_continue_statement ( - run, (xp_awk_nde_continue_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_CONTINUE: + { + if (__run_continue_statement ( + run, (xp_awk_nde_continue_t*)nde) == -1) return -1; + break; + } - case XP_AWK_NDE_RETURN: - if (__run_return_statement ( - run, (xp_awk_nde_return_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_RETURN: + { + if (__run_return_statement ( + run, (xp_awk_nde_return_t*)nde) == -1) return -1; + break; + } - case XP_AWK_NDE_EXIT: - if (__run_exit_statement ( - run, (xp_awk_nde_exit_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_EXIT: + { + if (__run_exit_statement ( + run, (xp_awk_nde_exit_t*)nde) == -1) return -1; + break; + } - case XP_AWK_NDE_NEXT: - if (__run_next_statement ( - run, (xp_awk_nde_next_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_NEXT: + { + if (__run_next_statement ( + run, (xp_awk_nde_next_t*)nde) == -1) return -1; + break; + } - case XP_AWK_NDE_NEXTFILE: - if (__run_nextfile_statement ( - run, (xp_awk_nde_nextfile_t*)nde) == -1) return -1; - break; + case XP_AWK_NDE_NEXTFILE: + { + if (__run_nextfile_statement ( + run, (xp_awk_nde_nextfile_t*)nde) == -1) return -1; + break; + } - default: + case XP_AWK_NDE_PRINT: + { + if (__run_print_statement ( + run, (xp_awk_nde_print_t*)nde) == -1) return -1; + break; + } + + default: { xp_awk_val_t* v; v = __eval_expression(run,nde); if (v == XP_NULL) return -1; xp_awk_refupval (v); xp_awk_refdownval (run, v); + break; } - break; } return 0; @@ -999,6 +1032,12 @@ static int __run_nextfile_statement (xp_awk_run_t* run, xp_awk_nde_nextfile_t* n return (n == -1)? -1: 0; } +static int __run_print_statement (xp_awk_run_t* run, xp_awk_nde_print_t* nde) +{ +xp_printf (XP_T("**** print NOT IMPLEMENTED...\n")); + return -1; +} + static xp_awk_val_t* __eval_expression (xp_awk_run_t* run, xp_awk_nde_t* nde) { static eval_expr_t __eval_func[] = diff --git a/ase/awk/tree.c b/ase/awk/tree.c index 11b25031..a54cbf6e 100644 --- a/ase/awk/tree.c +++ b/ase/awk/tree.c @@ -1,5 +1,5 @@ /* - * $Id: tree.c,v 1.51 2006-06-13 04:26:24 bacon Exp $ + * $Id: tree.c,v 1.52 2006-06-13 08:35:53 bacon Exp $ */ #include @@ -68,6 +68,12 @@ static const xp_char_t* __incop_str[] = XP_T("--") }; +static const xp_char_t* __print_outop_str[] = +{ + XP_T("|"), + XP_T(">") +}; + static void __print_tabs (int depth); static int __print_expression (xp_awk_nde_t* nde); static int __print_expression_list (xp_awk_nde_t* tree); @@ -341,20 +347,20 @@ static int __print_expression (xp_awk_nde_t* nde) if (px->cmd != XP_NULL) { __print_expression (px->cmd); - xp_printf (XP_TEXT(" | ")); + xp_printf (XP_T(" | ")); } - xp_printf (XP_TEXT("getline")); + xp_printf (XP_T("getline")); if (px->var != XP_NULL) { - xp_printf (XP_TEXT(" ")); + xp_printf (XP_T(" ")); __print_expression (px->var); } - if (px->out != XP_NULL) + if (px->in != XP_NULL) { - xp_printf (XP_TEXT(" < ")); - __print_expression (px->out); + xp_printf (XP_T(" < ")); + __print_expression (px->in); } break; } @@ -392,205 +398,270 @@ static void __print_statements (xp_awk_nde_t* tree, int depth) switch (p->type) { - case XP_AWK_NDE_NULL: - __print_tabs (depth); - xp_printf (XP_T(";\n")); - break; - - case XP_AWK_NDE_BLK: - __print_tabs (depth); - xp_printf (XP_T("{\n")); - - if (((xp_awk_nde_blk_t*)p)->nlocals > 0) - { - __print_tabs (depth + 1); - xp_printf (XP_T("local ")); - - for (i = 0; i < ((xp_awk_nde_blk_t*)p)->nlocals - 1; i++) - { - xp_printf (XP_T("__local%lu, "), (unsigned long)i); - } - xp_printf (XP_T("__local%lu;\n"), (unsigned long)i); - } - - __print_statements (((xp_awk_nde_blk_t*)p)->body, depth + 1); - __print_tabs (depth); - xp_printf (XP_T("}\n")); - break; - - case XP_AWK_NDE_IF: - __print_tabs (depth); - xp_printf (XP_T("if (")); - __print_expression (((xp_awk_nde_if_t*)p)->test); - xp_printf (XP_T(")\n")); - - xp_assert (((xp_awk_nde_if_t*)p)->then_part != XP_NULL); - if (((xp_awk_nde_if_t*)p)->then_part->type == XP_AWK_NDE_BLK) - __print_statements (((xp_awk_nde_if_t*)p)->then_part, depth); - else - __print_statements (((xp_awk_nde_if_t*)p)->then_part, depth + 1); - - if (((xp_awk_nde_if_t*)p)->else_part != XP_NULL) + case XP_AWK_NDE_NULL: { __print_tabs (depth); - xp_printf (XP_T("else\n")); - if (((xp_awk_nde_if_t*)p)->else_part->type == XP_AWK_NDE_BLK) - __print_statements (((xp_awk_nde_if_t*)p)->else_part, depth); - else - __print_statements (((xp_awk_nde_if_t*)p)->else_part, depth + 1); - } - break; - case XP_AWK_NDE_WHILE: - __print_tabs (depth); - xp_printf (XP_T("while (")); - __print_expression (((xp_awk_nde_while_t*)p)->test); - xp_printf (XP_T(")\n")); - if (((xp_awk_nde_while_t*)p)->body->type == XP_AWK_NDE_BLK) - { - __print_statements (((xp_awk_nde_while_t*)p)->body, depth); - } - else - { - __print_statements (((xp_awk_nde_while_t*)p)->body, depth + 1); - } - break; - - case XP_AWK_NDE_DOWHILE: - __print_tabs (depth); - xp_printf (XP_T("do\n")); - if (((xp_awk_nde_while_t*)p)->body->type == XP_AWK_NDE_BLK) - { - __print_statements (((xp_awk_nde_while_t*)p)->body, depth); - } - else - { - __print_statements (((xp_awk_nde_while_t*)p)->body, depth + 1); - } - - __print_tabs (depth); - xp_printf (XP_T("while (")); - __print_expression (((xp_awk_nde_while_t*)p)->test); - xp_printf (XP_T(");\n")); - break; - - case XP_AWK_NDE_FOR: - __print_tabs (depth); - xp_printf (XP_T("for (")); - if (((xp_awk_nde_for_t*)p)->init != XP_NULL) - { - __print_expression (((xp_awk_nde_for_t*)p)->init); - } - xp_printf (XP_T("; ")); - if (((xp_awk_nde_for_t*)p)->test != XP_NULL) - { - __print_expression (((xp_awk_nde_for_t*)p)->test); - } - xp_printf (XP_T("; ")); - if (((xp_awk_nde_for_t*)p)->incr != XP_NULL) - { - __print_expression (((xp_awk_nde_for_t*)p)->incr); - } - xp_printf (XP_T(")\n")); - - if (((xp_awk_nde_for_t*)p)->body->type == XP_AWK_NDE_BLK) - { - __print_statements (((xp_awk_nde_for_t*)p)->body, depth); - } - else - { - __print_statements (((xp_awk_nde_for_t*)p)->body, depth + 1); - } - break; - - case XP_AWK_NDE_FOREACH: - __print_tabs (depth); - xp_printf (XP_T("for ")); - __print_expression (((xp_awk_nde_foreach_t*)p)->test); - xp_printf (XP_T("\n")); - if (((xp_awk_nde_foreach_t*)p)->body->type == XP_AWK_NDE_BLK) - { - __print_statements (((xp_awk_nde_foreach_t*)p)->body, depth); - } - else - { - __print_statements (((xp_awk_nde_foreach_t*)p)->body, depth + 1); - } - break; - - case XP_AWK_NDE_BREAK: - __print_tabs (depth); - xp_printf (XP_T("break;\n")); - break; - - case XP_AWK_NDE_CONTINUE: - __print_tabs (depth); - xp_printf (XP_T("continue;\n")); - break; - - case XP_AWK_NDE_RETURN: - __print_tabs (depth); - if (((xp_awk_nde_return_t*)p)->val == XP_NULL) - { - xp_printf (XP_T("return;\n")); - } - else - { - xp_printf (XP_T("return ")); - xp_assert (((xp_awk_nde_return_t*)p)->val->next == XP_NULL); - if (__print_expression(((xp_awk_nde_return_t*)p)->val) == 0) - { - xp_printf (XP_T(";\n")); - } - else - { - xp_awk_nde_return_t* x = (xp_awk_nde_return_t*)p; - xp_printf (XP_T("***INTERNAL ERROR: unknown nde type - %d\n"), x->type); - } - } - break; - - case XP_AWK_NDE_EXIT: - __print_tabs (depth); - - if (((xp_awk_nde_exit_t*)p)->val == XP_NULL) - { - xp_printf (XP_T("exit;\n")); - } - else - { - xp_printf (XP_T("exit ")); - xp_assert (((xp_awk_nde_exit_t*)p)->val->next == XP_NULL); - if (__print_expression(((xp_awk_nde_exit_t*)p)->val) == 0) - { - xp_printf (XP_T(";\n")); - } - else - { - xp_awk_nde_exit_t* x = (xp_awk_nde_exit_t*)p; - xp_printf (XP_T("***INTERNAL ERROR: unknown nde type - %d\n"), x->type); - } - } - break; - - case XP_AWK_NDE_NEXT: - __print_tabs (depth); - xp_printf (XP_T("next;\n")); - break; - - case XP_AWK_NDE_NEXTFILE: - __print_tabs (depth); - xp_printf (XP_T("nextfile;\n")); - break; - - default: - __print_tabs (depth); - if (__print_expression(p) == 0) - { xp_printf (XP_T(";\n")); + break; } - else + + case XP_AWK_NDE_BLK: { - xp_printf (XP_T("***INTERNAL ERROR: unknown type - %d\n"), p->type); + xp_awk_nde_blk_t* px = (xp_awk_nde_blk_t*)p; + + __print_tabs (depth); + xp_printf (XP_T("{\n")); + + if (px->nlocals > 0) + { + __print_tabs (depth + 1); + xp_printf (XP_T("local ")); + + for (i = 0; i < px->nlocals - 1; i++) + { + xp_printf (XP_T("__local%lu, "), (unsigned long)i); + } + xp_printf (XP_T("__local%lu;\n"), (unsigned long)i); + } + + __print_statements (px->body, depth + 1); + __print_tabs (depth); + xp_printf (XP_T("}\n")); + break; + } + + case XP_AWK_NDE_IF: + { + xp_awk_nde_if_t* px = (xp_awk_nde_if_t*)p; + + __print_tabs (depth); + xp_printf (XP_T("if (")); + __print_expression (px->test); + xp_printf (XP_T(")\n")); + + xp_assert (px->then_part != XP_NULL); + if (px->then_part->type == XP_AWK_NDE_BLK) + __print_statements (px->then_part, depth); + else + __print_statements (px->then_part, depth + 1); + + if (px->else_part != XP_NULL) + { + __print_tabs (depth); + xp_printf (XP_T("else\n")); + if (px->else_part->type == XP_AWK_NDE_BLK) + __print_statements (px->else_part, depth); + else + __print_statements (px->else_part, depth + 1); + } + break; + } + + case XP_AWK_NDE_WHILE: + { + xp_awk_nde_while_t* px = (xp_awk_nde_while_t*)p; + + __print_tabs (depth); + xp_printf (XP_T("while (")); + __print_expression (px->test); + xp_printf (XP_T(")\n")); + if (px->body->type == XP_AWK_NDE_BLK) + { + __print_statements (px->body, depth); + } + else + { + __print_statements (px->body, depth + 1); + } + break; + } + + case XP_AWK_NDE_DOWHILE: + { + xp_awk_nde_while_t* px = (xp_awk_nde_while_t*)p; + + __print_tabs (depth); + xp_printf (XP_T("do\n")); + if (px->body->type == XP_AWK_NDE_BLK) + { + __print_statements (px->body, depth); + } + else + { + __print_statements (px->body, depth + 1); + } + + __print_tabs (depth); + xp_printf (XP_T("while (")); + __print_expression (px->test); + xp_printf (XP_T(");\n")); + break; + } + + case XP_AWK_NDE_FOR: + { + xp_awk_nde_for_t* px = (xp_awk_nde_for_t*)p; + + __print_tabs (depth); + xp_printf (XP_T("for (")); + if (px->init != XP_NULL) + { + __print_expression (px->init); + } + xp_printf (XP_T("; ")); + if (px->test != XP_NULL) + { + __print_expression (px->test); + } + xp_printf (XP_T("; ")); + if (px->incr != XP_NULL) + { + __print_expression (px->incr); + } + xp_printf (XP_T(")\n")); + + if (px->body->type == XP_AWK_NDE_BLK) + { + __print_statements (px->body, depth); + } + else + { + __print_statements (px->body, depth + 1); + } + break; + } + + case XP_AWK_NDE_FOREACH: + { + xp_awk_nde_foreach_t* px = (xp_awk_nde_foreach_t*)p; + + __print_tabs (depth); + xp_printf (XP_T("for ")); + __print_expression (px->test); + xp_printf (XP_T("\n")); + if (px->body->type == XP_AWK_NDE_BLK) + { + __print_statements (px->body, depth); + } + else + { + __print_statements (px->body, depth + 1); + } + break; + } + + case XP_AWK_NDE_BREAK: + { + __print_tabs (depth); + xp_printf (XP_T("break;\n")); + break; + } + + case XP_AWK_NDE_CONTINUE: + { + __print_tabs (depth); + xp_printf (XP_T("continue;\n")); + break; + } + + case XP_AWK_NDE_RETURN: + { + __print_tabs (depth); + if (((xp_awk_nde_return_t*)p)->val == XP_NULL) + { + xp_printf (XP_T("return;\n")); + } + else + { + xp_printf (XP_T("return ")); + xp_assert (((xp_awk_nde_return_t*)p)->val->next == XP_NULL); + if (__print_expression(((xp_awk_nde_return_t*)p)->val) == 0) + { + xp_printf (XP_T(";\n")); + } + else + { + xp_awk_nde_return_t* x = (xp_awk_nde_return_t*)p; + xp_printf (XP_T("***INTERNAL ERROR: unknown nde type - %d\n"), x->type); + } + } + break; + } + + case XP_AWK_NDE_EXIT: + { + xp_awk_nde_exit_t* px = (xp_awk_nde_exit_t*)p; + __print_tabs (depth); + + if (px->val == XP_NULL) + { + xp_printf (XP_T("exit;\n")); + } + else + { + xp_printf (XP_T("exit ")); + xp_assert (px->val->next == XP_NULL); + if (__print_expression(px->val) == 0) + { + xp_printf (XP_T(";\n")); + } + else + { + xp_printf (XP_T("***INTERNAL ERROR: unknown nde type - %d\n"), px->type); + } + } + break; + } + + case XP_AWK_NDE_NEXT: + { + __print_tabs (depth); + xp_printf (XP_T("next;\n")); + break; + } + + case XP_AWK_NDE_NEXTFILE: + { + __print_tabs (depth); + xp_printf (XP_T("nextfile;\n")); + break; + } + + case XP_AWK_NDE_PRINT: + { + xp_awk_nde_print_t* px = (xp_awk_nde_print_t*)p; + + __print_tabs (depth); + + xp_printf (XP_T("print")); + if (px->args != XP_NULL) + { + xp_printf (XP_T(" ")); + __print_expression_list (px->args); + } + + if (px->out != XP_NULL) + { + xp_printf (XP_T(" %s "), + __print_outop_str[px->out_type]); + __print_expression (px->out); + } + + xp_printf (XP_T(";\n")); + break; + } + + default: + { + __print_tabs (depth); + if (__print_expression(p) == 0) + { + xp_printf (XP_T(";\n")); + } + else + { + xp_printf (XP_T("***INTERNAL ERROR: unknown type - %d\n"), p->type); + } } } @@ -843,6 +914,16 @@ void xp_awk_clrpt (xp_awk_nde_t* tree) (xp_awk_nde_getline_t*)p; if (px->var != XP_NULL) xp_awk_clrpt (px->var); if (px->cmd != XP_NULL) xp_awk_clrpt (px->cmd); + if (px->in != XP_NULL) xp_awk_clrpt (px->in); + xp_free (p); + break; + } + + case XP_AWK_NDE_PRINT: + { + xp_awk_nde_print_t* px = + (xp_awk_nde_print_t*)p; + if (px->args != XP_NULL) xp_awk_clrpt (px->args); if (px->out != XP_NULL) xp_awk_clrpt (px->out); xp_free (p); break; diff --git a/ase/awk/tree.h b/ase/awk/tree.h index 60299488..9a5bdcb2 100644 --- a/ase/awk/tree.h +++ b/ase/awk/tree.h @@ -1,5 +1,5 @@ /* - * $Id: tree.h,v 1.42 2006-06-12 15:11:02 bacon Exp $ + * $Id: tree.h,v 1.43 2006-06-13 08:35:53 bacon Exp $ */ #ifndef _XP_AWK_TREE_H_ @@ -53,7 +53,14 @@ enum XP_AWK_NDE_LOCALIDX, XP_AWK_NDE_ARGIDX, XP_AWK_NDE_POS, - XP_AWK_NDE_GETLINE + XP_AWK_NDE_GETLINE, + XP_AWK_NDE_PRINT +}; + +enum +{ + XP_AWK_PRINT_PIPE, + XP_AWK_PRINT_FILE }; typedef struct xp_awk_func_t xp_awk_func_t; @@ -73,6 +80,7 @@ typedef struct xp_awk_nde_rex_t xp_awk_nde_rex_t; typedef struct xp_awk_nde_var_t xp_awk_nde_var_t; typedef struct xp_awk_nde_call_t xp_awk_nde_call_t; typedef struct xp_awk_nde_getline_t xp_awk_nde_getline_t; +typedef struct xp_awk_nde_print_t xp_awk_nde_print_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; @@ -208,6 +216,15 @@ struct xp_awk_nde_getline_t XP_AWK_NDE_HDR; xp_awk_nde_t* var; xp_awk_nde_t* cmd; + xp_awk_nde_t* in; +}; + +/* XP_AWK_NDE_PRINT */ +struct xp_awk_nde_print_t +{ + XP_AWK_NDE_HDR; + xp_awk_nde_t* args; + int out_type; /* XP_AWK_PRINT_PIPE, XP_AWK_PRINT_FILE */ xp_awk_nde_t* out; };