From 145c854513ee91d1564058d7fdf059f856f4eb58 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 24 Apr 2006 15:34:52 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk.c | 4 +-- ase/awk/parse.c | 67 ++++++++++++++++++++++++++++++++++++++----------- ase/awk/run.c | 15 ++++++++--- 3 files changed, 66 insertions(+), 20 deletions(-) diff --git a/ase/awk/awk.c b/ase/awk/awk.c index 5357c259..5ca8f0b6 100644 --- a/ase/awk/awk.c +++ b/ase/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.46 2006-04-24 14:38:46 bacon Exp $ + * $Id: awk.c,v 1.47 2006-04-24 15:34:52 bacon Exp $ */ #include @@ -95,10 +95,10 @@ int xp_awk_close (xp_awk_t* awk) return 0; } + /* TODO: write a function to clear awk->parse data structure. this would be need either as a separate function or as a part of xp_awk_clear... do i have to pass an option to xp_awk_clear to do this??? */ - void xp_awk_clear (xp_awk_t* awk) { /* TODO: kill all associated run instances... */ diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 9680cd2f..c5f1e420 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.90 2006-04-24 11:36:12 bacon Exp $ + * $Id: parse.c,v 1.91 2006-04-24 15:34:52 bacon Exp $ */ #include @@ -115,6 +115,7 @@ static xp_awk_nde_t* __parse_block (xp_awk_t* awk, xp_bool_t is_top); static xp_awk_nde_t* __parse_statement (xp_awk_t* awk); static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk); static xp_awk_nde_t* __parse_expression (xp_awk_t* awk); +static xp_awk_nde_t* __parse_assignment (xp_awk_t* awk); static xp_awk_nde_t* __parse_basic_expr (xp_awk_t* awk); @@ -384,24 +385,40 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk) { if (__parse_begin(awk) == XP_NULL) return XP_NULL; } - else if (MATCH(awk, TOKEN_END)) + else if (MATCH(awk,TOKEN_END)) { if (__parse_end(awk) == XP_NULL) return XP_NULL; } - /* TODO: process patterns and expressions */ - /* - expressions - /regular expression/ - pattern && pattern - pattern || pattern - !pattern - (pattern) - pattern, pattern - */ - else + else if (MATCH(awk,TOKEN_LBRACE)) { if (__parse_patternless(awk) == XP_NULL) return XP_NULL; } + else + { + /* TODO: process patterns and expressions */ + /* + expressions + /regular expression/ + pattern && pattern + pattern || pattern + !pattern + (pattern) + pattern, pattern + */ + + if (__parse_expression (awk) == XP_NULL) return XP_NULL; + if (MATCH(awk,TOKEN_LBRACE)) + { + if (__parse_patternless(awk) == XP_NULL) return XP_NULL; + } + else + { + /* { print $0; } */ + /* TODO: XXXX */ + xp_printf (XP_TEXT("BLOCKLESS NOT IMPLEMENTED....\n")); + PANIC (awk, XP_AWK_EINTERNAL); + } + } return awk; } @@ -656,7 +673,7 @@ static xp_awk_nde_t* __parse_patternless (xp_awk_t* awk) nde = __parse_action (awk); if (nde == XP_NULL) return XP_NULL; - chain = (xp_awk_chain_t*)xp_malloc(xp_sizeof(xp_awk_chain_t)); + chain = (xp_awk_chain_t*) xp_malloc (xp_sizeof(xp_awk_chain_t)); if (chain == XP_NULL) { xp_awk_clrpt (nde); @@ -1042,6 +1059,26 @@ static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk) } static xp_awk_nde_t* __parse_expression (xp_awk_t* awk) +{ + xp_awk_nde_t* nde, * tmp; + + do + { + tmp = __parse_assignment(awk); + if (tmp == XP_NULL) return XP_NULL; + + nde = tmp; break; /* TODO */ + + if (!match(awk, TOKEN_COMMA)) break; + if (__get_token(awk) == -1) return XP_NULL; + } + while (1); + +/* TODO: XP_AWK_NDE_GRP -> should i support i this way??? */ + return nde; +} + +static xp_awk_nde_t* __parse_assignment (xp_awk_t* awk) { /* * ::= | @@ -1088,7 +1125,7 @@ static xp_awk_nde_t* __parse_expression (xp_awk_t* awk) return XP_NULL; } - nde = (xp_awk_nde_ass_t*)xp_malloc(xp_sizeof(xp_awk_nde_ass_t)); + nde = (xp_awk_nde_ass_t*) xp_malloc (xp_sizeof(xp_awk_nde_ass_t)); if (nde == XP_NULL) { xp_awk_clrpt (x); diff --git a/ase/awk/run.c b/ase/awk/run.c index ecc5b6b0..e5fa7297 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.72 2006-04-24 14:38:46 bacon Exp $ + * $Id: run.c,v 1.73 2006-04-24 15:34:52 bacon Exp $ */ #include @@ -56,6 +56,8 @@ static int __run_nextfile_statement (xp_awk_run_t* run, xp_awk_nde_nextfile_t* n static xp_awk_val_t* __eval_expression ( xp_awk_run_t* run, xp_awk_nde_t* nde); +static xp_awk_val_t* __eval_group (xp_awk_run_t* run, xp_awk_nde_t* nde); + static xp_awk_val_t* __eval_assignment ( xp_awk_run_t* run, xp_awk_nde_t* nde); static xp_awk_val_t* __do_assignment ( @@ -467,8 +469,6 @@ static int __run_pattern_blocks (xp_awk_run_t* run) return 0; } - - static int __run_block (xp_awk_run_t* run, xp_awk_nde_blk_t* nde) { xp_awk_nde_t* p; @@ -833,6 +833,7 @@ static xp_awk_val_t* __eval_expression (xp_awk_run_t* run, xp_awk_nde_t* nde) { /* the order of functions here should match the order * of node types declared in tree.h */ + __eval_group, __eval_assignment, __eval_binary, __eval_unary, @@ -860,6 +861,14 @@ static xp_awk_val_t* __eval_expression (xp_awk_run_t* run, xp_awk_nde_t* nde) return __eval_func[nde->type-XP_AWK_NDE_ASS] (run, nde); } +static xp_awk_val_t* __eval_group (xp_awk_run_t* run, xp_awk_nde_t* nde) +{ + /* NOT INIMPELMETED YET */ +xp_printf (XP_TEXT("eval_group not implemented\n")); + PANIC (awk, XP_AWK_EINTERNAL); + return XP_NULL; +} + static xp_awk_val_t* __eval_assignment (xp_awk_run_t* run, xp_awk_nde_t* nde) { xp_awk_val_t* val, * res;