From 1765ee450dee1101535f6a3704f3e202a93deffd Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 22 Apr 2006 16:16:40 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk.h | 4 +++- ase/awk/err.c | 4 +++- ase/awk/parse.c | 15 ++++++++------- ase/awk/run.c | 26 ++++++++++++++++++++++---- ase/awk/tree.h | 16 +++++++++++++++- 5 files changed, 51 insertions(+), 14 deletions(-) diff --git a/ase/awk/awk.h b/ase/awk/awk.h index a921a6c3..8ed5d95f 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.54 2006-04-22 13:54:52 bacon Exp $ + * $Id: awk.h,v 1.55 2006-04-22 16:16:40 bacon Exp $ */ #ifndef _XP_AWK_AWK_H_ @@ -52,10 +52,12 @@ enum XP_AWK_ESRCINOPEN, XP_AWK_ESRCINCLOSE, + XP_AWK_ESRCINNEXT, XP_AWK_ESRCINDATA, /* error in reading source */ XP_AWK_ETXTINOPEN, XP_AWK_ETXTINCLOSE, + XP_AWK_ETXTINNEXT, XP_AWK_ETXTINDATA, /* error in reading text */ XP_AWK_ELXCHR, /* lexer came accross an wrong character */ diff --git a/ase/awk/err.c b/ase/awk/err.c index 6e57417e..802e4839 100644 --- a/ase/awk/err.c +++ b/ase/awk/err.c @@ -1,5 +1,5 @@ /* - * $Id: err.c,v 1.13 2006-04-22 13:54:52 bacon Exp $ + * $Id: err.c,v 1.14 2006-04-22 16:16:40 bacon Exp $ */ #include @@ -18,10 +18,12 @@ const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk) XP_TEXT("cannot open source input"), XP_TEXT("cannot close source input"), + XP_TEXT("cannot switch to next source input"), XP_TEXT("cannot read source input"), XP_TEXT("cannot open text input"), XP_TEXT("cannot close text input"), + XP_TEXT("cannot switch to next text input"), XP_TEXT("cannot read text input"), XP_TEXT("invalid character"), diff --git a/ase/awk/parse.c b/ase/awk/parse.c index bb504608..0007efca 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.86 2006-04-22 13:54:52 bacon Exp $ + * $Id: parse.c,v 1.87 2006-04-22 16:16:40 bacon Exp $ */ #include @@ -2269,26 +2269,27 @@ static xp_awk_nde_t* __parse_delete (xp_awk_t* awk) static xp_awk_nde_t* __parse_next (xp_awk_t* awk) { - xp_awk_nde_t* nde; + xp_awk_nde_next_t* nde; - nde = (xp_awk_nde_t*)xp_malloc(xp_sizeof(xp_awk_nde_t)); + nde = (xp_awk_nde_next_t*) xp_malloc (xp_sizeof(xp_awk_nde_next_t)); if (nde == XP_NULL) PANIC (awk, XP_AWK_ENOMEM); nde->type = XP_AWK_NDE_NEXT; nde->next = XP_NULL; - return nde; + return (xp_awk_nde_t*)nde; } static xp_awk_nde_t* __parse_nextfile (xp_awk_t* awk) { - xp_awk_nde_t* nde; + xp_awk_nde_nextfile_t* nde; - nde = (xp_awk_nde_t*)xp_malloc(xp_sizeof(xp_awk_nde_t)); + nde = (xp_awk_nde_nextfile_t*) + xp_malloc (xp_sizeof(xp_awk_nde_nextfile_t)); if (nde == XP_NULL) PANIC (awk, XP_AWK_ENOMEM); nde->type = XP_AWK_NDE_NEXTFILE; nde->next = XP_NULL; - return nde; + return (xp_awk_nde_t*)nde; } static int __get_token (xp_awk_t* awk) diff --git a/ase/awk/run.c b/ase/awk/run.c index fe3d7693..a26524cc 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.68 2006-04-22 13:54:52 bacon Exp $ + * $Id: run.c,v 1.69 2006-04-22 16:16:40 bacon Exp $ */ #include @@ -50,6 +50,8 @@ static int __run_break_statement (xp_awk_run_t* run, xp_awk_nde_break_t* nde); static int __run_continue_statement (xp_awk_run_t* run, xp_awk_nde_continue_t* nde); 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 xp_awk_val_t* __eval_expression ( xp_awk_run_t* run, xp_awk_nde_t* nde); @@ -570,11 +572,13 @@ static int __run_statement (xp_awk_run_t* run, xp_awk_nde_t* nde) break; case XP_AWK_NDE_NEXT: - /* TODO: */ + if (__run_next_statement ( + run, (xp_awk_nde_next_t*)nde) == -1) return -1; break; case XP_AWK_NDE_NEXTFILE: - /* TODO: */ + if (__run_nextfile_statement ( + run, (xp_awk_nde_nextfile_t*)nde) == -1) return -1; break; default: @@ -809,6 +813,20 @@ static int __run_exit_statement (xp_awk_run_t* run, xp_awk_nde_exit_t* nde) return 0; } +static int __run_next_statement (xp_awk_run_t* run, xp_awk_nde_next_t* nde) +{ + /* TODO */ + return -1; +} + +static int __run_nextfile_statement (xp_awk_run_t* run, xp_awk_nde_nextfile_t* nde) +{ + xp_ssize_t n; + n = run->txtio (XP_AWK_INPUT_NEXT, run->txtio_arg, XP_NULL, 0); + if (n == -1) PANIC_I (run, XP_AWK_ETXTINNEXT); + return (n == -1)? -1: 0; +} + static xp_awk_val_t* __eval_expression (xp_awk_run_t* run, xp_awk_nde_t* nde) { static eval_expr_t __eval_func[] = @@ -2620,7 +2638,7 @@ static xp_char_t* __val_to_str (xp_awk_val_t* v, int* errnum) return tmp; } - /* TODO: process more value types */ +/* TODO: process more value types */ *errnum = XP_AWK_EWRONGINDEX; return XP_NULL; diff --git a/ase/awk/tree.h b/ase/awk/tree.h index a04baab6..b5481a7d 100644 --- a/ase/awk/tree.h +++ b/ase/awk/tree.h @@ -1,5 +1,5 @@ /* - * $Id: tree.h,v 1.35 2006-04-18 16:04:59 bacon Exp $ + * $Id: tree.h,v 1.36 2006-04-22 16:16:40 bacon Exp $ */ #ifndef _XP_AWK_TREE_H_ @@ -74,6 +74,8 @@ typedef struct xp_awk_nde_break_t xp_awk_nde_break_t; typedef struct xp_awk_nde_continue_t xp_awk_nde_continue_t; typedef struct xp_awk_nde_return_t xp_awk_nde_return_t; typedef struct xp_awk_nde_exit_t xp_awk_nde_exit_t; +typedef struct xp_awk_nde_next_t xp_awk_nde_next_t; +typedef struct xp_awk_nde_nextfile_t xp_awk_nde_nextfile_t; struct xp_awk_func_t { @@ -229,6 +231,18 @@ struct xp_awk_nde_exit_t xp_awk_nde_t* val; /* optional (no exit code if XP_NULL) */ }; +/* XP_AWK_NDE_NEXT */ +struct xp_awk_nde_next_t +{ + XP_AWK_NDE_HDR; +}; + +/* XP_AWK_NDE_NEXTFILE */ +struct xp_awk_nde_nextfile_t +{ + XP_AWK_NDE_HDR; +}; + #ifdef __cplusplus extern "C" { #endif