From e5224ad96dd9a26baa9c7785b6a40f0be90aeb1e Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 24 Apr 2006 11:26:00 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk.h | 3 ++- ase/awk/err.c | 3 ++- ase/awk/parse.c | 4 ++-- ase/awk/run.c | 4 +++- ase/awk/tree.c | 12 +++++++++++- ase/awk/tree.h | 13 ++++++++++++- ase/awk/val.c | 34 +++++++++++++++++++++++++++++++++- ase/awk/val.h | 15 +++++++++++++-- 8 files changed, 78 insertions(+), 10 deletions(-) diff --git a/ase/awk/awk.h b/ase/awk/awk.h index 8ed5d95f..747369d8 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.55 2006-04-22 16:16:40 bacon Exp $ + * $Id: awk.h,v 1.56 2006-04-24 11:25:59 bacon Exp $ */ #ifndef _XP_AWK_AWK_H_ @@ -65,6 +65,7 @@ enum XP_AWK_EENDSRC, /* unexpected end of source */ XP_AWK_EENDSTR, /* unexpected end of a string */ + XP_AWK_EENDREX, /* unexpected end of a regular expression */ XP_AWK_ELBRACE, /* left brace expected */ XP_AWK_ELPAREN, /* left parenthesis expected */ XP_AWK_ERPAREN, /* right parenthesis expected */ diff --git a/ase/awk/err.c b/ase/awk/err.c index 802e4839..4f16dd30 100644 --- a/ase/awk/err.c +++ b/ase/awk/err.c @@ -1,5 +1,5 @@ /* - * $Id: err.c,v 1.14 2006-04-22 16:16:40 bacon Exp $ + * $Id: err.c,v 1.15 2006-04-24 11:25:59 bacon Exp $ */ #include @@ -31,6 +31,7 @@ const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk) XP_TEXT("unexpected end of source"), XP_TEXT("unexpected end of a string"), + XP_TEXT("unexpected end of a regular expression"), XP_TEXT("left brace expected"), XP_TEXT("left parenthesis expected"), XP_TEXT("right parenthesis expected"), diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 15046de5..1172ac4d 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.88 2006-04-24 11:22:42 bacon Exp $ + * $Id: parse.c,v 1.89 2006-04-24 11:25:59 bacon Exp $ */ #include @@ -2832,7 +2832,7 @@ static int __get_regex (xp_awk_t* awk) { if (c == XP_CHAR_EOF) { - awk->errnum = XP_AWK_EENDSTR; + awk->errnum = XP_AWK_EENDREX; return -1; } diff --git a/ase/awk/run.c b/ase/awk/run.c index 987acff4..05ab3568 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.70 2006-04-24 11:22:42 bacon Exp $ + * $Id: run.c,v 1.71 2006-04-24 11:26:00 bacon Exp $ */ #include @@ -1809,6 +1809,7 @@ static xp_awk_val_t* __eval_binop_ma ( xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right) { /* TODO: ... */ +xp_printf (XP_TEXT("eval_binop_ma not implemented yet...\n")); PANIC (run, XP_AWK_EINTERNAL); return XP_NULL; } @@ -2385,6 +2386,7 @@ static xp_awk_val_t* __eval_str (xp_awk_run_t* run, xp_awk_nde_t* nde) static xp_awk_val_t* __eval_rex (xp_awk_run_t* run, xp_awk_nde_t* nde) { /* TODO */ +xp_printf (XP_TEXT("eval_rex not implemented yet...\n")); PANIC (run, XP_AWK_EINTERNAL); return XP_NULL; } diff --git a/ase/awk/tree.c b/ase/awk/tree.c index fac3536a..98e1e5dc 100644 --- a/ase/awk/tree.c +++ b/ase/awk/tree.c @@ -1,5 +1,5 @@ /* - * $Id: tree.c,v 1.39 2006-04-16 16:30:59 bacon Exp $ + * $Id: tree.c,v 1.40 2006-04-24 11:22:42 bacon Exp $ */ #include @@ -169,6 +169,11 @@ static int __print_expression (xp_awk_nde_t* nde) xp_printf (XP_TEXT("\"%s\""), ((xp_awk_nde_str_t*)nde)->buf); break; + case XP_AWK_NDE_REX: + /* TODO: buf, len */ + xp_printf (XP_TEXT("/%s/"), ((xp_awk_nde_rex_t*)nde)->buf); + break; + case XP_AWK_NDE_ARG: xp_assert (((xp_awk_nde_var_t*)nde)->id.idxa != (xp_size_t)-1); xp_printf (XP_TEXT("__arg%lu"), @@ -604,6 +609,11 @@ void xp_awk_clrpt (xp_awk_nde_t* tree) xp_free (p); break; + case XP_AWK_NDE_REX: + xp_free (((xp_awk_nde_rex_t*)p)->buf); + xp_free (p); + break; + case XP_AWK_NDE_NAMED: xp_assert (((xp_awk_nde_var_t*)p)->id.name != XP_NULL); case XP_AWK_NDE_GLOBAL: diff --git a/ase/awk/tree.h b/ase/awk/tree.h index b5481a7d..31ec26be 100644 --- a/ase/awk/tree.h +++ b/ase/awk/tree.h @@ -1,5 +1,5 @@ /* - * $Id: tree.h,v 1.36 2006-04-22 16:16:40 bacon Exp $ + * $Id: tree.h,v 1.37 2006-04-24 11:22:42 bacon Exp $ */ #ifndef _XP_AWK_TREE_H_ @@ -41,6 +41,7 @@ enum XP_AWK_NDE_INT, XP_AWK_NDE_REAL, XP_AWK_NDE_STR, + XP_AWK_NDE_REX, XP_AWK_NDE_NAMED, XP_AWK_NDE_GLOBAL, XP_AWK_NDE_LOCAL, @@ -64,6 +65,7 @@ typedef struct xp_awk_nde_pos_t xp_awk_nde_pos_t; typedef struct xp_awk_nde_int_t xp_awk_nde_int_t; typedef struct xp_awk_nde_real_t xp_awk_nde_real_t; typedef struct xp_awk_nde_str_t xp_awk_nde_str_t; +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; @@ -158,6 +160,15 @@ struct xp_awk_nde_str_t xp_size_t len; }; +/* XP_AWK_NDE_REX */ +struct xp_awk_nde_rex_t +{ + XP_AWK_NDE_HDR; +/* TODO: */ + xp_char_t* buf; + xp_size_t len; +}; + struct xp_awk_nde_var_t { XP_AWK_NDE_HDR; diff --git a/ase/awk/val.c b/ase/awk/val.c index 65528cf1..8c271bea 100644 --- a/ase/awk/val.c +++ b/ase/awk/val.c @@ -1,5 +1,5 @@ /* - * $Id: val.c,v 1.25 2006-04-21 17:24:31 bacon Exp $ + * $Id: val.c,v 1.26 2006-04-24 11:22:42 bacon Exp $ */ #include @@ -120,6 +120,27 @@ xp_awk_val_t* xp_awk_makestrval2 ( return (xp_awk_val_t*)val; } +xp_awk_val_t* xp_awk_makerexval (const xp_char_t* str, xp_size_t len) +{ + xp_awk_val_rex_t* val; + +/* TDOO: XXXXXXXXXXXXxxx */ + val = (xp_awk_val_rex_t*)xp_malloc(xp_sizeof(xp_awk_val_rex_t)); + if (val == XP_NULL) return XP_NULL; + + val->type = XP_AWK_VAL_STR; + val->ref = 0; + val->len = len; + val->buf = xp_strxdup (str, len); + if (val->buf == XP_NULL) + { + xp_free (val); + return XP_NULL; + } + + return (xp_awk_val_t*)val; +} + static void __free_map_val (void* run, void* v) { /* @@ -149,6 +170,7 @@ xp_awk_val_t* xp_awk_makemapval (xp_awk_run_t* run) return (xp_awk_val_t*)val; } + xp_bool_t xp_awk_isbuiltinval (xp_awk_val_t* val) { return val == XP_NULL || val == xp_awk_val_nil || @@ -194,6 +216,12 @@ xp_printf (XP_TEXT("\n")); xp_free (val); return; + case XP_AWK_VAL_REX: +/* TODO: XXXX */ + xp_free (((xp_awk_val_rex_t*)val)->buf); + xp_free (val); + return; + case XP_AWK_VAL_MAP: xp_awk_map_close (((xp_awk_val_map_t*)val)->map); xp_free (val); @@ -335,6 +363,10 @@ void xp_awk_printval (xp_awk_val_t* val) xp_printf (XP_TEXT("%s"), ((xp_awk_val_str_t*)val)->buf); break; + case XP_AWK_VAL_REX: + xp_printf (XP_TEXT("REX[%s]"), ((xp_awk_val_rex_t*)val)->buf); + break; + case XP_AWK_VAL_MAP: xp_printf (XP_TEXT("MAP[")); xp_awk_map_walk (((xp_awk_val_map_t*)val)->map, __print_pair); diff --git a/ase/awk/val.h b/ase/awk/val.h index 231e22f7..550b71c1 100644 --- a/ase/awk/val.h +++ b/ase/awk/val.h @@ -1,5 +1,5 @@ /* - * $Id: val.h,v 1.19 2006-04-21 17:24:31 bacon Exp $ + * $Id: val.h,v 1.20 2006-04-24 11:22:42 bacon Exp $ */ #ifndef _XP_AWK_VAL_H_ @@ -15,7 +15,8 @@ enum XP_AWK_VAL_INT = 1, XP_AWK_VAL_REAL = 2, XP_AWK_VAL_STR = 3, - XP_AWK_VAL_MAP = 4 + XP_AWK_VAL_REX = 4, + XP_AWK_VAL_MAP = 5 }; typedef struct xp_awk_val_t xp_awk_val_t; @@ -23,6 +24,7 @@ typedef struct xp_awk_val_nil_t xp_awk_val_nil_t; typedef struct xp_awk_val_int_t xp_awk_val_int_t; typedef struct xp_awk_val_real_t xp_awk_val_real_t; typedef struct xp_awk_val_str_t xp_awk_val_str_t; +typedef struct xp_awk_val_rex_t xp_awk_val_rex_t; typedef struct xp_awk_val_map_t xp_awk_val_map_t; #define XP_AWK_VAL_HDR \ @@ -67,6 +69,14 @@ struct xp_awk_val_str_t xp_size_t len; }; +/* XP_AWK_VAL_REX */ +struct xp_awk_val_rex_t +{ + XP_AWK_VAL_HDR; + xp_char_t* buf; + xp_size_t len; +}; + /* XP_AWK_VAL_MAP */ struct xp_awk_val_map_t { @@ -86,6 +96,7 @@ xp_awk_val_t* xp_awk_makestrval (const xp_char_t* str, xp_size_t len); xp_awk_val_t* xp_awk_makestrval2 ( const xp_char_t* str1, xp_size_t len1, const xp_char_t* str2, xp_size_t len2); +xp_awk_val_t* xp_awk_makerexval (const xp_char_t* str, xp_size_t len); xp_awk_val_t* xp_awk_makemapval (xp_awk_run_t* run); xp_bool_t xp_awk_isbuiltinval (xp_awk_val_t* val);